:root {
  --bg: #ffffff;
  --surface: #f5f6f8;
  --surface-2: #ffffff;
  --text: #14161a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2b7cff;
  --accent-text: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 20, 30, .06), 0 8px 24px rgba(16, 20, 30, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --surface: #1e2127;
    --surface-2: #23262d;
    --text: #f2f3f5;
    --muted: #9aa1ad;
    --border: #2e323a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.state {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 16px 16px 96px; max-width: 720px; margin: 0 auto; }

.shop-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  object-fit: cover;
  background: var(--surface);
  flex: none;
}

.shop-head h1 { font-size: 20px; margin: 0; line-height: 1.2; }
.shop-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.toolbar { margin-bottom: 12px; }

.search {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
}

.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}

.chip[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

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

@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  color: inherit;
  font: inherit;
  box-shadow: var(--shadow);
}

.card:active { transform: scale(.99); }

.card__img {
  aspect-ratio: 1 / 1;
  width: 100%;
  object-fit: cover;
  background: var(--surface);
  display: block;
}

.card__img--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 24px;
}

.card__body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.card__title { font-size: 14px; line-height: 1.3; }
.card__price { font-size: 14px; font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 32px 0; }

.ask {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), 688px);
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }

.sheet__body {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}

.sheet__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.gallery::-webkit-scrollbar { display: none; }

.gallery img {
  width: 78%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
  flex: none;
  background: var(--surface);
}

.sheet__body h2 { margin: 0 0 6px; font-size: 19px; }
.price { margin: 0 0 12px; font-size: 17px; font-weight: 600; }
.desc { margin: 0 0 16px; color: var(--muted); white-space: pre-wrap; }

.comment { display: block; margin-bottom: 12px; }
.comment span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.comment textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.contact {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.contact:disabled { opacity: .6; cursor: default; }

.status { margin: 10px 0 0; text-align: center; font-size: 14px; color: var(--muted); min-height: 20px; }
