:root {
  --bg: #f2f4f6;
  --text: #191f28;
  --sub: #6b7684;
  --faint: #8b95a1;
  --line: #f2f4f6;
  --field: #f2f4f6;
  --red: #e5323c;
  --blue: #3182f6;
  color-scheme: light;
}
* { box-sizing: border-box; }
p { margin: 0; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 0 0;
}
header > * { max-width: 640px; margin-left: auto; margin-right: auto; padding-left: 16px; padding-right: 16px; }
h1 { margin-bottom: 12px; font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }

.search { position: relative; display: flex; gap: 8px; margin-bottom: 0; }
.search .glass {
  position: absolute;
  left: 30px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--faint);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.search input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 14px 0 40px;
  border: 0;
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { box-shadow: inset 0 0 0 2px var(--blue); background: #fff; }
.cam {
  display: grid;
  padding: 0;
  border: 0;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--text);
  cursor: pointer;
}
.cam svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linejoin: round; }
.cam:active { transform: scale(0.96); }
.cam.busy { opacity: 0.4; pointer-events: none; }
.status { padding-top: 8px; font-size: 13px; color: var(--sub); }
.status:empty { display: none; }
.status.err { color: var(--red); }

#cats {
  display: flex;
  gap: 20px;
  margin-top: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid #e5e8eb;
}
#cats::-webkit-scrollbar { display: none; }
#cats button {
  flex: none;
  padding: 10px 0 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--faint);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
#cats button.on { color: var(--text); border-bottom-color: var(--text); }

main { max-width: 640px; margin: 0 auto; padding: 0 12px; }
.caption { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 2px 8px 6px; font-size: 13px; color: var(--sub); }
#sort {
  appearance: none;
  -webkit-appearance: none;
  height: 32px;
  padding: 0 26px 0 10px;
  border: 0;
  border-radius: 8px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%236b7684' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 12px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

#list { list-style: none; margin: 0; padding: 0; background: #fff; border-radius: 16px; overflow: hidden; }
.row + .row .head { border-top: 1px solid var(--line); }
.head { display: flex; gap: 14px; padding: 14px 16px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.head:active { background: #f9fafb; }
.bottle {
  flex: none;
  width: 60px;
  height: 80px;
  padding: 4px;
  border-radius: 10px;
  background: #f9fafb;
  object-fit: contain;
  mix-blend-mode: multiply;
}
.bottle.none { display: block; }
img.bottle { cursor: zoom-in; }

#viewer {
  width: min(92vw, 520px);
  max-height: 90vh;
  padding: 20px 20px 16px;
  border: 0;
  border-radius: 20px;
  background: #fff;
  overflow: hidden;
  outline: none;
  text-align: center;
  cursor: zoom-out;
}
#viewer::backdrop { background: rgba(0, 0, 0, 0.55); }
#viewer img { display: block; width: 100%; max-height: calc(90vh - 90px); object-fit: contain; mix-blend-mode: multiply; }
#viewer p { margin-top: 10px; font-size: 15px; font-weight: 600; }
.body { flex: 1; min-width: 0; }
.name { display: flex; align-items: baseline; gap: 6px; }
.name strong { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name span { flex: none; font-size: 12px; color: var(--faint); }
.sub { margin-top: 1px; font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp { margin-top: 8px; display: grid; gap: 2px; }
.pp p { display: flex; align-items: baseline; gap: 6px; font-size: 15px; white-space: nowrap; }
.pp .lb { width: 26px; flex: none; font-size: 13px; color: var(--sub); }
.pp b { font-weight: 600; }
.pp .krw { font-size: 13px; color: var(--sub); }
.pct { font-size: 12px; font-weight: 600; color: var(--red); }
.pct.up { color: var(--blue); }

.detail { padding: 0 16px 16px 90px; font-size: 14px; }
.range { font-size: 13px; color: var(--sub); }
.verdict { margin-top: 6px; font-weight: 500; }
.cheap { color: var(--red); }
.calc { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.calc input[type="number"] {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: var(--field);
  font: inherit;
  font-size: 16px;
  outline: none;
}
.calc input[type="number"]:focus { box-shadow: inset 0 0 0 2px var(--blue); background: #fff; }
.calc .tax { display: flex; align-items: center; gap: 5px; flex: none; color: var(--sub); font-size: 14px; }
.calc .tax input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
output { display: block; margin-top: 8px; font-size: 14px; }
output:empty { display: none; }
.info { margin-top: 12px; font-size: 12px; color: var(--faint); }
.info summary { cursor: pointer; }
.info p { margin-top: 6px; }
.info a { color: inherit; }

.empty { padding: 48px 16px; text-align: center; color: var(--sub); }

footer { max-width: 640px; margin: 0 auto; padding: 20px 18px calc(32px + env(safe-area-inset-bottom)); font-size: 12px; color: var(--faint); }
footer p + p { margin-top: 8px; }

@media (max-width: 380px) {
  .detail { padding-left: 16px; }
}

#camera {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  outline: none;
}
#camera::backdrop { background: #000; }
#camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#camera .hint {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-size: 14px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
#camera .bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.45);
}
#camera .bar button { min-width: 64px; padding: 10px; border: 0; background: none; color: #fff; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
#camera .bar .shutter {
  width: 72px;
  height: 72px;
  min-width: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.45), 0 0 0 7px #fff;
}
#camera .bar .shutter:active { transform: scale(0.94); }
