:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --text: #171b24;
  --muted: #687083;
  --line: #dfe3ea;
  --brand: #df1a20;
  --brand-strong: #b81218;
  --accent: #1f7a5c;
  --shadow: 0 10px 30px rgba(23, 27, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.app-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.search-form {
  display: flex;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.search-form input {
  min-width: 0;
  flex: 1;
  border: 0;
  padding: 12px 14px;
  outline: none;
}

.search-form button,
.paging-status {
  border: 0;
  background: var(--brand);
  color: white;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 48px;
}

.store-tabs,
.segmented {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab-button,
.segment-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 16px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.tab-button.active,
.segment-button.active {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

#categorySelect {
  min-height: 42px;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 12px;
}

.status-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 22px 0 12px;
}

.status-row strong {
  font-size: 20px;
}

.status-row span {
  color: var(--muted);
  font-size: 14px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.product-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.product-media {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 0.78;
  padding: 16px;
  background: #fdfdfd;
}

.product-media img {
  max-width: 100%;
  max-height: 150px;
  object-fit: contain;
}

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.product-info {
  padding: 13px 14px 15px;
}

.product-title {
  display: -webkit-box;
  min-height: 44px;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 16px;
  line-height: 1.35;
}

.product-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.product-price {
  margin-top: 8px;
  color: var(--brand);
  font-size: 15px;
  font-weight: 800;
}

.empty-state {
  display: grid;
  gap: 6px;
  place-items: center;
  min-height: 180px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.empty-state[hidden] {
  display: none;
}

.empty-state strong {
  color: var(--text);
}

.paging-status,
.end-state {
  width: max-content;
  max-width: 100%;
  margin: 22px auto 0;
  border-radius: 8px;
  min-height: 40px;
  padding: 10px 16px;
  font-weight: 700;
}

.paging-status[hidden],
.end-state[hidden] {
  display: none;
}

.end-state {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.scroll-sentinel {
  height: 1px;
}

.scroll-top-button {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  box-shadow: 0 10px 24px rgba(23, 27, 36, 0.24);
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.scroll-top-button[hidden] {
  display: none;
}

@media (max-width: 860px) {
  .header-inner,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  #categorySelect {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .product-grid {
    gap: 10px;
  }

  h1 {
    font-size: 24px;
  }

  .product-media {
    padding: 10px;
  }

  .product-media img {
    max-height: 118px;
  }

  .product-info {
    padding: 11px 10px 12px;
  }

  .product-title {
    font-size: 14px;
  }

  .product-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
  }

  .scroll-top-button {
    right: 14px;
    width: 48px;
    height: 48px;
  }
}
