:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e6e8ec;
  --text: #16181d;
  --muted: #6b7280;
  --accent: #ef4a3c;
  --accent-soft: #ffece9;
  --chip: #f1f3f6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .04);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101114;
    --panel: #171a1f;
    --line: #262a31;
    --text: #e9eaee;
    --muted: #9aa1ad;
    --accent: #ff6b5c;
    --accent-soft: #2a1a18;
    --chip: #1f232a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------ header */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 16px 10px;
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark { font-size: 22px; line-height: 1; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 17px; letter-spacing: -.02em; }
.brand-text small { color: var(--muted); font-size: 11.5px; }

.top-actions { display: flex; align-items: center; gap: 10px; }
.updated { color: var(--muted); font-size: 12px; white-space: nowrap; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 8px 13px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { border-color: #c9ced6; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.05); border-color: var(--accent); }
.btn[disabled] { opacity: .55; cursor: default; }

/* ------------------------------------------------------------ categories */
.cats {
  display: flex;
  gap: 6px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }

.cat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.cat[aria-selected="true"] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}
.cat .n { font-size: 11.5px; font-weight: 700; opacity: .75; }

/* ------------------------------------------------------------ filters */
.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px 10px;
  flex-wrap: wrap;
}

.sources { display: flex; gap: 6px; flex-wrap: wrap; }
.src {
  border: 1px solid var(--line);
  background: var(--chip);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.src[aria-pressed="true"] {
  background: var(--text);
  color: var(--panel);
  border-color: var(--text);
}
.src .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  background: #9ca3af;
  vertical-align: 1px;
}
.src[data-ok="true"] .dot { background: #22c55e; }
.src[data-ok="false"] .dot { background: #ef4444; }

.tools { display: flex; gap: 8px; align-items: center; }
.search input {
  width: 210px;
  max-width: 46vw;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13.5px;
}
.search input:focus, select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 1px;
}
select {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13.5px;
}

.notice {
  max-width: 1180px;
  margin: 0 auto 10px;
  padding: 9px 16px;
  font-size: 12.5px;
  color: #92400e;
  background: #fef3c7;
  border-top: 1px solid #fde68a;
  border-bottom: 1px solid #fde68a;
}
@media (prefers-color-scheme: dark) {
  .notice { color: #fcd34d; background: #2a2314; border-color: #3b3220; }
}

/* 제휴(대가성) 고지 — 필터 바로 아래 상시 노출 */
.disclosure {
  max-width: 1180px;
  margin: 0 auto 10px;
  padding: 0 16px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  word-break: keep-all;
}

/* ------------------------------------------------------------ list */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.list-head { display: flex; justify-content: space-between; align-items: baseline; }
.count { margin: 2px 0 12px; color: var(--muted); font-size: 12.5px; }

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

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .1s;
  min-height: 132px;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); transform: translateY(-1px); }

.card-main { display: block; }

/* 카드 하단 동작 : 제휴/이동 버튼 + 원문 링크 */
.card-actions { display: flex; align-items: center; gap: 8px; }
.card-actions .btn-buy {
  flex: 1 1 auto;
  text-align: center;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  transition: filter .15s, transform .05s;
}
.card-actions .btn-buy:hover { filter: brightness(1.06); }
.card-actions .btn-buy:active { transform: translateY(1px); }
.origin-link {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.origin-link:hover { color: var(--text); }

.card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--chip);
  color: var(--muted);
}
.badge.cat-전자기기 { background: #e0ecff; color: #1d4ed8; }
.badge.cat-식품     { background: #e6f7e9; color: #15803d; }
.badge.cat-생활패션 { background: #fdeee0; color: #b45309; }
.badge.cat-게임SW   { background: #efe6ff; color: #6d28d9; }
.badge.cat-기타     { background: #eceff3; color: #475569; }
@media (prefers-color-scheme: dark) {
  .badge.cat-전자기기 { background: #17244a; color: #93b4ff; }
  .badge.cat-식품     { background: #13291a; color: #86efac; }
  .badge.cat-생활패션 { background: #2b1f12; color: #fdba74; }
  .badge.cat-게임SW   { background: #221838; color: #c4b5fd; }
  .badge.cat-기타     { background: #1f232a; color: #cbd5e1; }
}

.badge.flag { background: #fee2e2; color: #b91c1c; }
@media (prefers-color-scheme: dark) { .badge.flag { background: #3a1717; color: #fca5a5; } }

.card-body { display: flex; gap: 10px; align-items: flex-start; }

.thumb {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--chip);
}

.title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.card-bottom {
  margin-top: auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.price { font-size: 16.5px; font-weight: 800; letter-spacing: -.02em; }
.price.dim { font-size: 12.5px; font-weight: 600; color: var(--muted); }

.meta { display: flex; flex-direction: column; gap: 2px; text-align: right; }
.meta .store { font-size: 12px; font-weight: 600; color: var(--muted); }
.meta .when { font-size: 11.5px; color: var(--muted); }

.src-tag {
  font-size: 11px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  padding-left: 7px;
  margin-left: 2px;
}

.empty { text-align: center; padding: 60px 16px; color: var(--muted); }
.empty .hint { font-size: 13px; }
.more-wrap { display: flex; justify-content: center; margin-top: 18px; }
.more-wrap .btn { padding: 10px 22px; }

/* ------------------------------------------------------------ footer */
.foot {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 36px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.foot p { margin: 4px 0; }
.foot .muted { opacity: .8; }

.skeleton {
  height: 132px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--chip) 30%, var(--panel) 50%, var(--chip) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 720px) {
  .top-inner { padding: 10px 14px 8px; }
  .updated { display: none; }
  .filters { gap: 8px; }
  .tools { width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; max-width: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
  .card { padding: 12px; }
}
