:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #6b7280;
  --line: #dbe3ee;
  --gold: #b98a30;
  --sold: #b42318;
  --partial: #a16207;
  --consign: #0369a1;
  --ok: #047857;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef2f7;
  color: var(--ink);
  font-size: 22px;
}

.top-actions,
.top-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.link-btn {
  min-width: 52px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #eef2f7;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 12px;
}

.search-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-box {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  min-width: 0;
}

.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
}

.tab-btn,
.filter-row select {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--ink);
  font-size: 14px;
}

.tab-btn[aria-selected="true"] {
  border-color: var(--gold);
  background: #fff7e6;
  color: #7c4a03;
  font-weight: 700;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 8px;
}

.filter-row select {
  width: 100%;
  padding: 0 10px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}

.summary-strip div {
  min-height: 58px;
  padding: 9px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-strip strong,
.summary-strip span {
  display: block;
}

.summary-strip strong {
  font-size: 19px;
  line-height: 1.25;
}

.summary-strip span {
  color: var(--muted);
  font-size: 12px;
}

.product-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.product-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.image-frame {
  position: relative;
  width: 92px;
  height: 92px;
  overflow: hidden;
  border: 1px solid #e5eaf1;
  border-radius: 8px;
  background: #f2f5f9;
}

.image-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.image-badge {
  position: absolute;
  left: 5px;
  bottom: 5px;
  max-width: calc(100% - 10px);
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(23, 32, 51, 0.72);
  color: #fff;
  font-size: 10px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-info {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 7px;
}

.brand-line,
.meta-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.brand-line span:first-child,
.meta-line span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-pill {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 6px;
  background: #e8f0fa;
  color: #164e63;
  font-size: 11px;
  font-weight: 700;
}

.product-name {
  margin: 0;
  min-height: 40px;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.price {
  color: #111827;
  font-size: 20px;
  font-weight: 800;
}

.status {
  margin-left: auto;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.status.sold {
  background: #fee4e2;
  color: var(--sold);
}

.status.partial {
  background: #fef3c7;
  color: var(--partial);
}

.status.consign {
  background: #e0f2fe;
  color: var(--consign);
}

.status.other {
  background: #ecfdf3;
  color: var(--ok);
}

.review-note {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.detail-panel.open {
  pointer-events: auto;
}

.detail-scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0);
  transition: background 180ms ease;
}

.detail-panel.open .detail-scrim {
  background: rgba(15, 23, 42, 0.36);
}

.detail-sheet {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  max-height: 88vh;
  overflow: auto;
  padding: 16px;
  padding-bottom: calc(22px + env(safe-area-inset-bottom));
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateY(100%);
  transition: transform 210ms ease;
}

.detail-panel.open .detail-sheet {
  transform: translateY(0);
}

.detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.detail-title {
  padding-right: 40px;
}

.detail-title h2 {
  margin: 4px 0 10px;
  font-size: 20px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.detail-media {
  display: grid;
  gap: 10px;
  margin: 10px 0 14px;
}

.detail-media .image-frame {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
}

.detail-grid {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 9px 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  font-size: 14px;
}

.detail-grid dt {
  color: var(--muted);
}

.detail-grid dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 30px 10px;
  color: var(--muted);
  text-align: center;
}

.site-footer {
  padding: 22px 16px calc(22px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--ink);
  text-decoration: underline;
}

@media (min-width: 860px) {
  main {
    padding: 16px;
  }

  .search-panel {
    grid-template-columns: minmax(280px, 1fr) 360px 320px;
    align-items: center;
  }

  .detail-sheet {
    top: 0;
    left: auto;
    width: min(460px, 100%);
    max-height: 100vh;
    border-radius: 8px 0 0 8px;
    transform: translateX(100%);
  }

  .detail-panel.open .detail-sheet {
    transform: translateX(0);
  }
}
