/* 아기용품 가격비교 — 쇼핑몰형 레이아웃 */
:root {
  --bg: #f7f7f9;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --line: #e7e7ee;
  --line-strong: #d8d8e3;
  --text: #1c1c24;
  --text-2: #5a5a6e;
  --text-3: #8b8b9e;
  --accent: #ff6b81;
  --accent-ink: #ffffff;
  --accent-soft: #fff0f2;
  --good: #17a06b;
  --good-soft: #e8f7f0;
  --warn: #e4762a;
  --shadow: 0 1px 2px rgba(20, 20, 40, .05), 0 8px 24px rgba(20, 20, 40, .06);
  --radius: 14px;
  --naver: #03c75a;
  --bunjang: #ff5b3b;
  --daangn: #ff8a3d;
  --maxw: 1440px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131318;
    --surface: #1c1c24;
    --surface-2: #232330;
    --line: #2e2e3c;
    --line-strong: #3b3b4d;
    --text: #f2f2f7;
    --text-2: #b4b4c6;
    --text-3: #85859a;
    --accent: #ff7d91;
    --accent-ink: #24141a;
    --accent-soft: #35222a;
    --good: #3ecf95;
    --good-soft: #16352a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---------- 헤더 ---------- */
header.top {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 18px;
}
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; letter-spacing: -.02em; white-space: nowrap; }
.logo .mark { font-size: 22px; }
.logo small { color: var(--text-3); font-weight: 500; font-size: 11px; }

.searchbar { flex: 1; max-width: 520px; position: relative; }
.searchbar input {
  width: 100%; padding: 10px 14px 10px 38px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font-size: 14px;
}
.searchbar input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.searchbar .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.btn {
  padding: 9px 15px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.btn:hover { border-color: var(--text-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: default; }

.status-chip { font-size: 12px; color: var(--text-3); white-space: nowrap; }

/* 카테고리 바 */
.catbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.catbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 20px;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
}
.catbar-inner::-webkit-scrollbar { display: none; }
.catbar a {
  padding: 11px 13px; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.catbar a:hover { color: var(--text); }
.catbar a.on { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- 레이아웃 ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 22px 20px 60px; }
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 24px; align-items: start; }
/* grid/flex 자식은 min-width:auto 라 내용이 넓으면 칸을 밀어낸다. 0 으로 눌러야 안 넘친다. */
.layout > * { min-width: 0; }
@media (max-width: 1000px) { .layout { grid-template-columns: minmax(0, 1fr); } aside.filters { position: static; } }

aside.filters {
  position: sticky; top: 108px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.filters h4 { margin: 0 0 9px; font-size: 12px; letter-spacing: .04em; color: var(--text-3); text-transform: uppercase; }
.filters section + section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.filters label { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; color: var(--text-2); cursor: pointer; }
.filters label:hover { color: var(--text); }
.filters input[type=checkbox], .filters input[type=radio] { accent-color: var(--accent); width: 15px; height: 15px; }
.filters .count { margin-left: auto; font-size: 11px; color: var(--text-3); }
.price-inputs { display: flex; align-items: center; gap: 6px; }
.price-inputs input {
  width: 100%; min-width: 0; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text); font-size: 12.5px;
}
.scroll-list { max-height: 260px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }

/* ---------- 히어로 / 섹션 ---------- */
.hero {
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%);
  border: 1px solid var(--line); border-radius: 18px; padding: 22px 24px; margin-bottom: 24px;
}
.hero h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.03em; }
.hero p { margin: 0; color: var(--text-2); font-size: 13.5px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 26px; margin-top: 16px; }
.hero-stat b { display: block; font-size: 21px; letter-spacing: -.02em; }
.hero-stat span { font-size: 12px; color: var(--text-3); }

.section { margin-bottom: 34px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.section-head .sub { font-size: 12.5px; color: var(--text-3); }
.section-head .more { margin-left: auto; font-size: 13px; color: var(--accent); font-weight: 600; }

/* ---------- 카드 그리드 ---------- */
.grid { display: grid; gap: 14px; }
.grid.items { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid.listings { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card .thumb {
  aspect-ratio: 1 / 1; background: var(--surface-2); position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .thumb .placeholder { font-size: 34px; opacity: .3; }
.card .body { padding: 11px 12px 13px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .title {
  font-size: 13px; line-height: 1.4; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .price { font-size: 16.5px; font-weight: 800; letter-spacing: -.02em; }
.card .meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-3); margin-top: auto; flex-wrap: wrap; }

/* 품목 카드 (홈) */
.item-card .body { gap: 3px; }
.item-card .name { font-weight: 700; font-size: 14px; letter-spacing: -.01em; }
.item-card .medians { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.item-card .medians .used { font-size: 16px; font-weight: 800; }
.item-card .medians .new { font-size: 12px; color: var(--text-3); text-decoration: line-through; }
.item-card .cnt { font-size: 11.5px; color: var(--text-3); }

/* 뱃지 */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: -.01em;
  white-space: nowrap;   /* 좁은 칸에서 "당근마 / 켓" 으로 갈라지지 않게 */
}
.badge.src-naver { background: rgba(3, 199, 90, .13); color: var(--naver); }
.badge.src-bunjang { background: rgba(255, 91, 59, .13); color: var(--bunjang); }
.badge.src-daangn { background: rgba(255, 138, 61, .15); color: var(--daangn); }
.badge.deal { background: var(--accent); color: var(--accent-ink); }
.badge.save { background: var(--good-soft); color: var(--good); }
.badge.new { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.badge.reserved { background: var(--surface-2); color: var(--warn); border: 1px solid var(--line); }
.badge.drop { background: var(--accent-soft); color: var(--accent); }
/* 당근인데 택배가 되는 매물 — 동네가 멀어도 살 수 있다는 뜻이라 눈에 띄어야 한다. */
.badge.ship { background: var(--good-soft); color: var(--good); }

.thumb .corner { position: absolute; top: 8px; left: 8px; }

/* ---------- 품목 상세 ---------- */
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.detail-head h1 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.crumb { font-size: 12.5px; color: var(--text-3); margin-bottom: 14px; }
.crumb a:hover { color: var(--accent); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .k { font-size: 11.5px; color: var(--text-3); margin-bottom: 5px; }
.stat .v { font-size: 20px; font-weight: 800; letter-spacing: -.03em; }
.stat .sub { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.stat.accent { background: var(--accent-soft); border-color: transparent; }
.stat.accent .v { color: var(--accent); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 22px;
}
.panel h3 { margin: 0 0 4px; font-size: 15px; letter-spacing: -.02em; }
.panel .hint { font-size: 12px; color: var(--text-3); margin-bottom: 14px; }

/* 시세 분포 막대 */
.dist { margin-top: 8px; }
.dist-bar { position: relative; height: 34px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.dist-range { position: absolute; top: 0; bottom: 0; background: var(--accent-soft); }
.dist-median { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.dist-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 5px; }

/* 브랜드 표 */
table.brands { width: 100%; border-collapse: collapse; font-size: 13px; }
table.brands th {
  text-align: left; font-size: 11.5px; color: var(--text-3); font-weight: 600;
  padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.brands td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.brands tr:last-child td { border-bottom: none; }
table.brands tr.clickable:hover { background: var(--surface-2); cursor: pointer; }
table.brands td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.brands .bname { font-weight: 700; }
.minibar { height: 6px; border-radius: 3px; background: var(--accent); opacity: .8; min-width: 2px; }

/* 차트 */
.chart-wrap { overflow-x: auto; }
svg.chart { display: block; width: 100%; min-width: 460px; height: auto; }
svg.chart .grid-line { stroke: var(--line); stroke-width: 1; }
svg.chart .axis-label { fill: var(--text-3); font-size: 10px; }
svg.chart .band { fill: var(--accent); opacity: .13; }
svg.chart .line-used { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .line-new { fill: none; stroke: var(--text-3); stroke-width: 2; stroke-dasharray: 5 4; }
svg.chart .dot { fill: var(--accent); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend i { display: inline-block; width: 16px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* 툴바 */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
select.sort {
  padding: 8px 11px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font-size: 13px;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--text-2);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* 상태 표시 */
.empty { padding: 60px 20px; text-align: center; color: var(--text-3); }
.empty .big { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sh 1.3s infinite; border-radius: 8px; }
@keyframes sh { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.progress-wrap { position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 100; background: transparent; }
.progress-bar { height: 100%; background: var(--accent); width: 0; transition: width .3s; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 17px; box-shadow: var(--shadow); font-size: 13px; max-width: 340px;
}
.toast b { display: block; margin-bottom: 3px; }

.pager { display: flex; justify-content: center; gap: 8px; margin-top: 24px; }
.pager button { padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; }
.pager button:disabled { opacity: .4; }
.pager .now { font-size: 13px; color: var(--text-2); align-self: center; padding: 0 6px; }

footer.foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 20px; text-align: center; font-size: 12px; color: var(--text-3); }

/* ---------- 좁은 화면 ---------- */
/* ---------- 좁은 화면: 접이식 필터 ---------- */
.filter-fold > summary {
  cursor: pointer; list-style: none; font-size: 13.5px; font-weight: 700;
  padding: 2px 0; display: flex; align-items: center; gap: 7px; color: var(--text);
}
.filter-fold > summary::-webkit-details-marker { display: none; }
.filter-fold > summary::after {
  content: "▾"; margin-left: auto; color: var(--text-3); font-size: 12px; transition: transform .15s;
}
.filter-fold[open] > summary::after { transform: rotate(180deg); }
.filter-fold[open] > summary { margin-bottom: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.filter-fold > section:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }

@media (max-width: 760px) {
  /* 헤더를 두 줄로: 위에 로고+수집버튼, 아래에 검색창 통째로 */
  .top-inner { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .searchbar { order: 3; flex-basis: 100%; max-width: none; }
  .top-actions { margin-left: auto; }
  .status-chip { display: none; }        /* 같은 숫자를 홈 히어로가 보여준다 */
  .logo { font-size: 15px; }
  .logo small { display: none; }

  .wrap { padding: 16px 14px 44px; }
  /* 접어 두었으니 위로 올린다. 아래에 있으면 쓰려고 끝까지 내려야 한다. */
  .layout { gap: 14px; }
  aside.filters { order: 0; padding: 13px 15px; }
  main { order: 1; }

  .hero { padding: 18px 16px; border-radius: 14px; }
  .hero h1 { font-size: 19px; }
  .hero-stats { gap: 18px; }

  .detail-head h1 { font-size: 20px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 12px 13px; }
  .stat .v { font-size: 17px; }

  .section-head { flex-wrap: wrap; row-gap: 2px; }
  .section-head h2 { font-size: 15.5px; }
  .section-head .more { margin-left: auto; }

  .grid { gap: 10px; }
  .grid.items, .grid.listings { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .card .price { font-size: 15px; }

  .panel { padding: 15px 14px; }
  table.brands th, table.brands td { padding: 7px 6px; font-size: 12.5px; }
  svg.chart { min-width: 0; }
  svg.chart .axis-label { font-size: 15px; }   /* viewBox 기준이라 축소돼도 읽힌다 */
}

@media (max-width: 420px) {
  .grid.items, .grid.listings { grid-template-columns: repeat(2, 1fr); }
  .catbar a { padding: 10px 9px; font-size: 12.5px; }
}

/* ---------- 로그인 ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px; padding: 30px 28px; box-shadow: var(--shadow);
}
.auth-card .mark { font-size: 34px; display: block; margin-bottom: 10px; }
.auth-card h1 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.03em; }
.auth-card p.lead { margin: 0 0 22px; font-size: 13px; color: var(--text-2); line-height: 1.55; }
.auth-card label.f { display: block; margin-bottom: 13px; }
.auth-card label.f span { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 5px; }
.auth-card input {
  width: 100%; padding: 10px 13px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text); font-size: 14px;
}
.auth-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 6px; padding: 11px; }
.auth-msg { margin-top: 12px; font-size: 12.5px; min-height: 17px; }
.auth-switch { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text-3); text-align: center; }
.auth-switch a { color: var(--accent); font-weight: 600; cursor: pointer; }

/* 헤더 사용자 영역 */
.user-chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px;
  color: var(--text-2); padding: 5px 10px; border-radius: 999px; background: var(--surface-2);
}
.user-chip b { color: var(--text); font-weight: 700; }
.link-btn { background: none; border: none; color: var(--text-3); font-size: 12px; padding: 4px 6px; }
.link-btn:hover { color: var(--accent); }

@media (max-width: 760px) {
  .user-chip { display: none; }
}

/* 초대코드 */
.code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; font-weight: 700;
  letter-spacing: .08em; padding: 8px 12px; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent); display: inline-block;
}

/* 표는 좁은 화면에서 칸을 밀어낸다. 표만 따로 옆으로 스크롤되게 둔다. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap > table.brands { min-width: 100%; }

@media (max-width: 460px) {
  /* 아주 좁을 땐 덜 중요한 칸을 접어 스크롤할 일 자체를 줄인다 */
  table.brands th.opt, table.brands td.opt { display: none; }
}

/* 찜 별표 — 카드 전체가 링크라, 그 위에 떠 있는 버튼으로 둔다 */
.fav-btn {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: rgba(255, 255, 255, .86); color: var(--text-3);
  font-size: 16px; line-height: 1; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(20, 20, 40, .18); transition: transform .1s, color .1s;
}
.fav-btn:hover { transform: scale(1.1); color: var(--accent); }
.fav-btn.on { color: var(--accent); }
.fav-btn:disabled { opacity: .6; }
@media (prefers-color-scheme: dark) {
  .fav-btn { background: rgba(30, 30, 42, .9); }
}

/* 찜 목록의 상태 표시 */
.saved-gone { opacity: .55; }
.saved-row-note { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* 카테고리 줄 끝에 붙는 설정 항목 — 카테고리와 섞여 보이지 않게 선으로 가른다. */
.catbar a.nav-sep { border-left: 1px solid var(--line); margin-left: 6px; padding-left: 14px; }

/* 검색창 아래로 떨어지는 제안 목록 */
.suggest {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden;
}
.suggest-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px;
  background: none; border: none; text-align: left; color: var(--text); font-size: 13.5px;
}
.suggest-row:hover { background: var(--surface-2); }
.suggest-row span { margin-left: auto; font-size: 11.5px; color: var(--text-3); }

/* 홈 맨 위 "오늘 볼 것" 줄 */
.digest-row {
  display: flex; align-items: center; gap: 11px; padding: 10px 6px;
  border-radius: 10px; color: var(--text);
}
.digest-row + .digest-row { border-top: 1px solid var(--line); }
.digest-row:hover { background: var(--surface-2); }
.digest-row b { display: block; font-size: 13.5px; }
.digest-row span span { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.digest-row .go { margin-left: auto; color: var(--text-3); flex: none; }
