/* 우리집 장바구니 — 흑백 에디토리얼 스타일 (포인트 #1D4D7A) */

:root {
  --bg: #ffffff;
  --text: #000000;
  --sub: #5c5c5c;
  --muted: #9a9a9a;
  --line: #e6e6e6;
  --line-strong: #000000;
  --fill: #f4f4f4;
  --accent: #1D4D7A;
  --accent-soft: #eaf0f5;
  --on-accent: #ffffff;
  --danger: #c0392b;
  --pad: 20px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  letter-spacing: -0.01em;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.eyebrow {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent);
}

/* ------------------------------------------------ 헤더 */
.topbar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: env(safe-area-inset-top) var(--pad) 0;
  border-bottom: 1px solid var(--line);
}
.brandrow { display: flex; align-items: center; justify-content: space-between; height: 44px; max-width: 960px; margin: 0 auto; }
.logo { font-size: 15px; font-weight: 800; letter-spacing: 0.04em; text-decoration: none; }
.me-link { border: 0; background: none; padding: 6px 0; font-size: 13px; color: var(--sub); text-decoration: underline; text-underline-offset: 3px; }
.mainnav { display: flex; gap: 22px; max-width: 960px; margin: 0 auto; }
.mainnav button {
  border: 0; background: none; padding: 4px 0 12px; font-size: 24px; font-weight: 800; letter-spacing: -0.03em;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.mainnav button.active { color: var(--text); border-bottom-color: var(--text); }

main { max-width: 960px; margin: 0 auto; padding: 0 var(--pad); }

/* ------------------------------------------------ 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--text); background: var(--text); color: var(--bg);
  border-radius: 0; padding: 0 18px; height: 44px; font-size: 14px; font-weight: 700;
  white-space: nowrap; text-decoration: none;
}
.btn.line { background: transparent; color: var(--text); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn:disabled { opacity: .4; }
.btn:active { opacity: .7; }
.textbtn { border: 0; background: none; padding: 4px 0; font-size: 13px; color: var(--sub); text-decoration: underline; text-underline-offset: 3px; }
.textbtn.danger, .danger { color: var(--danger); }

/* ------------------------------------------------ 빠른 추가 + 필터 */
.quickadd { display: flex; gap: 0; margin-top: 24px; border-bottom: 2px solid var(--text); }
.quickadd input {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 0; outline: none;
  font-size: 20px; font-weight: 700; letter-spacing: -0.02em;
}
.quickadd input::placeholder { color: var(--muted); font-weight: 600; }
.quickadd .btn { height: auto; padding: 0 4px 0 14px; background: none; border: 0; color: var(--accent); font-size: 15px; }
.qa-wrap { position: relative; z-index: 4; }
.suggest {
  position: absolute; left: 0; right: 0; top: 100%; margin: 0; padding: 0; list-style: none;
  background: var(--bg); border: 1px solid var(--text); border-top: 0; box-shadow: 0 12px 24px rgba(0, 0, 0, .08);
  max-height: 340px; overflow-y: auto;
}
.suggest li + li { border-top: 1px solid var(--line); }
.suggest .sug-head { padding: 10px 14px 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; color: var(--accent); }
.suggest button {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border: 0; background: none; padding: 13px 14px; text-align: left;
}
.suggest button:hover, .suggest button.on { background: var(--fill); }
.sug-name { font-size: 15px; font-weight: 500; }
.sug-name b { font-weight: 800; color: var(--accent); }
.sug-note { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.sug-note.mine { color: var(--accent); font-weight: 700; }
.quickadd-hint {font-size: 12.5px; color: var(--sub); margin: 8px 0 0; min-height: 19px; }
.quickadd-hint b { color: var(--accent); font-weight: 700; }
.quickadd-hint button { border: 0; background: none; color: var(--accent); padding: 0 2px; text-decoration: underline; font-size: 12.5px; font-weight: 700; }

.filters { display: flex; gap: 18px; margin: 22px 0 8px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
  border: 0; background: none; padding: 8px 0 10px; font-size: 14px; font-weight: 600; color: var(--muted);
  white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.filters button.active { color: var(--text); font-weight: 800; border-bottom-color: var(--accent); }

/* ------------------------------------------------ 목록 */
.group { margin-top: 36px; }
.group-h { margin-bottom: 4px; }
.group-h h2, .page-h h2 { margin: 4px 0 0; font-size: 26px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.2; }
.group-h h2 em { font-style: normal; font-size: 15px; font-weight: 700; color: var(--accent); margin-left: 8px; vertical-align: 4px; }
.page-h { margin: 28px 0 8px; }
.empty { color: var(--muted); font-size: 13.5px; padding: 26px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 12px; }

.card {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 18px 0;
}
.card-main { display: flex; gap: 16px; align-items: center; }
.card .shop { display: flex; gap: 6px; margin-top: 12px; }
.card .shop a {
  flex: 1; text-align: center; padding: 7px 0; border: 1px solid var(--line); font-size: 12px; font-weight: 700;
  text-decoration: none; color: var(--text); background: var(--bg);
}
.card .shop a:active { background: var(--text); color: var(--bg); }
@media (hover: hover) { .card .shop a:hover { border-color: var(--text); } }
.group-h + .card { border-top: 1px solid var(--line-strong); margin-top: 12px; }
.card:active { background: var(--fill); }
.card .body { flex: 1; min-width: 0; }
.card .cat { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.card .flag { color: var(--accent); font-weight: 800; margin-left: 4px; }
.card .name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.card .sub { font-size: 12.5px; color: var(--sub); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .right { text-align: right; flex: none; }
.card .right .price { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }
.card .right .price.light { font-weight: 600; color: var(--sub); font-size: 14px; }
.card .right .sub { font-size: 12px; color: var(--muted); }
.card.alert .name { color: var(--accent); }

details.stocked summary { list-style: none; cursor: pointer; }
details.stocked summary::-webkit-details-marker { display: none; }
details.stocked summary h2::after { content: "＋"; font-size: 18px; font-weight: 400; color: var(--muted); float: right; margin-top: 4px; }
details.stocked[open] summary h2::after { content: "－"; }
details.stocked[open] summary { margin-bottom: 12px; }
details.stocked .card:first-of-type { border-top: 1px solid var(--line-strong); }

/* ------------------------------------------------ 구매 기록 */
.month-h {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 32px 0 0; padding-bottom: 10px; border-bottom: 1px solid var(--line-strong);
  font-size: 20px; font-weight: 800; letter-spacing: -0.02em;
}
.month-h span:last-child { font-size: 16px; }
.plist .p { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: center; cursor: pointer; }
.plist .p .body { flex: 1; min-width: 0; font-size: 14px; }
.plist .p .pname { font-weight: 700; }
.plist .p .sub { font-size: 12.5px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plist .p .amt { font-weight: 800; white-space: nowrap; }

/* ------------------------------------------------ 상세 시트 */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(16px); opacity: 0; } }
.sheet-inner { max-width: 960px; margin: 0 auto; padding: calc(6px + env(safe-area-inset-top)) var(--pad) 48px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; height: 48px; margin-bottom: 8px; }
.sheet-head .back { border: 0; background: none; font-size: 24px; padding: 0 12px 0 0; line-height: 1; }
.sheet .title { margin: 6px 0 14px; font-size: 32px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.15; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 14px; font-size: 12.5px; color: var(--sub); }
.meta-row select { border: 1px solid var(--line); background: var(--bg); border-radius: 0; padding: 5px 8px; font-size: 13px; font-weight: 600; }
.memo {
  width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; border-radius: 0;
  padding: 10px 0; resize: vertical; min-height: 42px; margin-bottom: 14px; font-size: 14px; outline: none;
}
.memo:focus { border-bottom-color: var(--text); }
.status-actions { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.banner { background: var(--accent-soft); border-left: 3px solid var(--accent); padding: 12px 14px; font-size: 13.5px; margin-bottom: 14px; }
.banner b { color: var(--accent); }
.sheet-foot { text-align: center; margin-top: 40px; }

.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 18px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.tabs button {
  flex: 1; border: 0; background: none; padding: 14px 0 12px; font-size: 14.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--text); font-weight: 800; border-bottom-color: var(--text); }

/* ------------------------------------------------ 검색 + 상품 그리드 */
.searchbar { display: flex; gap: 8px; margin-bottom: 14px; }
.searchbar input { flex: 1; min-width: 0; border: 1px solid var(--text); background: var(--bg); border-radius: 0; padding: 0 12px; height: 44px; outline: none; font-weight: 600; }
.sortbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.sortbar .seg { white-space: nowrap; flex: none; }
.sortbar .seg button { border: 0; background: none; color: var(--muted); padding: 2px 0 2px 12px; font-size: 12.5px; font-weight: 600; }
.sortbar .seg button.active { color: var(--text); font-weight: 800; }

.block { margin-bottom: 26px; }
.srcs { display: flex; gap: 16px; margin: -4px 0 18px; border-bottom: 1px solid var(--line); }
.srcs button { border: 0; background: none; padding: 6px 0 9px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.srcs button.active { color: var(--text); font-weight: 800; border-bottom-color: var(--accent); }
.pship { font-size: 11.5px; color: var(--muted); }
.more-ways { border-top: 1px solid var(--line-strong); margin-top: 8px; padding-top: 4px; }
.more-ways summary { list-style: none; cursor: pointer; padding: 14px 0; font-size: 14px; font-weight: 800; display: flex; justify-content: space-between; }
.more-ways summary::-webkit-details-marker { display: none; }
.more-ways summary::after { content: "＋"; font-weight: 400; color: var(--muted); }
.more-ways[open] summary::after { content: "－"; }
.k { font-size: 12px; font-weight: 800; letter-spacing: 0.01em; margin-bottom: 8px; display: block; }
.sortbar .k { margin: 0; color: var(--text); }
.mall-links { display: flex; flex-wrap: wrap; border-top: 1px solid var(--line-strong); }
.mall-links a {
  flex: 1 1 33%; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 10px 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; font-size: 14px; font-weight: 700;
}
.mall-links a:nth-child(3n+2), .mall-links a:nth-child(3n+3) { padding-left: 10px; border-left: 1px solid var(--line); }
.mall-links a span { color: var(--muted); font-weight: 400; }
.linkform .row { display: flex; gap: 6px; }
.linkform input { flex: 1; min-width: 0; border: 1px solid var(--text); border-radius: 0; padding: 0 10px; height: 44px; font-size: 14px; outline: none; background: var(--bg); }
.linkform .btn { padding: 0 12px; }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.note { background: var(--fill); padding: 14px 16px; font-size: 13px; color: var(--sub); line-height: 1.55; }
.disclosure { margin: 18px 0 0; font-size: 11px; color: var(--muted); }
.import-img { width: 96px; height: 96px; object-fit: cover; background: var(--fill); }

.pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 12px; }
@media (min-width: 640px) { .pgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .pgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pcard { display: flex; flex-direction: column; min-width: 0; }
.pimg {
  position: relative; display: grid; place-items: center; aspect-ratio: 1 / 1; background: var(--fill);
  overflow: hidden; margin-bottom: 10px; text-decoration: none;
}
.pimg img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.pimg span { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: 0.08em; }
.pimg .badge {
  position: absolute; left: 0; top: 0; font-style: normal; background: var(--accent); color: var(--on-accent);
  font-size: 11px; font-weight: 800; padding: 4px 8px; letter-spacing: 0.02em;
}
.pmall { font-size: 12px; font-weight: 800; margin-bottom: 2px; }
.ptitle { font-size: 13px; color: var(--sub); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 36px; }
.pprice { font-size: 16px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.punit { font-size: 12.5px; font-weight: 800; color: var(--accent); margin-top: 1px; }
.punit span { color: var(--muted); font-weight: 500; margin-left: 2px; }
.pbtn { margin-top: 10px; width: 100%; }
.padded { margin-top: 10px; height: 32px; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------ 비교 */
.compare-wrap { overflow-x: auto; }
.compare { width: 100%; border-collapse: collapse; font-size: 13.5px; border-top: 1px solid var(--line-strong); }
.compare th, .compare td { padding: 14px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.compare th:first-child, .compare td:first-child { padding-left: 0; }
.compare th:last-child, .compare td:last-child { padding-right: 0; }
.compare th { font-size: 11.5px; color: var(--muted); font-weight: 700; letter-spacing: 0.02em; }
.compare td.num { text-align: right; white-space: nowrap; font-weight: 700; }
.compare td.acts { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.compare tr.best td:first-child > div:first-child { font-weight: 800; }
.compare a { font-size: 12px; color: var(--sub); }
.compare .diff { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.tag { display: inline-block; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 800; padding: 2px 7px; margin-top: 4px; }

.dcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0; border-top: 1px solid var(--line-strong); }
.dcard { padding: 18px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
@media (min-width: 640px) { .dcard { padding: 18px 16px 18px 0; } }
.dcard .dimg { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; }
.dcard .title { font-size: 15px; font-weight: 700; }
.dcard .price { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.dcard .meta { font-size: 12px; color: var(--muted); }
.dcard textarea { border: 1px solid var(--line); background: var(--bg); border-radius: 0; padding: 8px 10px; font-size: 13px; min-height: 70px; resize: vertical; outline: none; }
.dcard textarea:focus { border-color: var(--text); }
.dcard .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.stat { padding: 14px 0; }
.stat + .stat { border-left: 1px solid var(--line); padding-left: 14px; }
.stat .k { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }

/* ------------------------------------------------ 시작 화면 */
.login { max-width: 420px; margin: 0 auto; padding: 48px 0 24px; display: flex; flex-direction: column; gap: 16px; }
.login .hero { margin: 0; font-size: 44px; font-weight: 800; letter-spacing: -0.05em; line-height: 1.08; }
.login > p { margin: 0 0 12px; color: var(--sub); font-size: 14.5px; }
.login label { font-size: 12px; font-weight: 700; color: var(--text); display: flex; flex-direction: column; gap: 4px; }
.login input {
  border: 0; border-bottom: 2px solid var(--text); background: transparent; border-radius: 0;
  padding: 10px 0; font-size: 18px; font-weight: 600; outline: none;
}
.login input::placeholder { color: var(--muted); font-weight: 500; }
.login .btn { height: 52px; font-size: 15px; }
.login .banner { margin: 0; }
.login-err { color: var(--danger); font-size: 13px; }
.login-err:empty { display: none; }
.join-box { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; }
.join-box summary { cursor: pointer; font-size: 13.5px; font-weight: 700; list-style: none; text-decoration: underline; text-underline-offset: 3px; }
.join-box summary::-webkit-details-marker { display: none; }
.join-box[open] { display: flex; flex-direction: column; gap: 10px; }
.join-box p { margin: 0; font-size: 13px; color: var(--sub); }
.join-box input { font-size: 14px; border-bottom-width: 1px; }

/* ------------------------------------------------ 다이얼로그 */
dialog {
  border: 0; border-radius: 0; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--bg); color: var(--text); border-top: 3px solid var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .5); }
@media (max-width: 520px) {
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
dialog form { padding: 24px var(--pad); display: flex; flex-direction: column; gap: 12px; }
dialog h3 { margin: 0 0 2px; font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
dialog p { margin: 0; color: var(--sub); font-size: 13px; }
dialog label { font-size: 12px; font-weight: 700; display: flex; flex-direction: column; gap: 2px; }
dialog input, dialog select {
  border: 0; border-bottom: 1px solid var(--line); background: transparent; border-radius: 0;
  padding: 9px 0; font-size: 16px; color: var(--text); outline: none;
}
dialog input:focus { border-bottom-color: var(--text); }
dialog .btns { display: flex; gap: 8px; margin-top: 10px; }
dialog .btns .btn { flex: 1; }
dialog .banner { margin: 0; font-size: 12.5px; }
dialog .members { border-top: 1px solid var(--line-strong); margin-top: 6px; }
dialog .members .k { font-size: 11.5px; color: var(--muted); font-weight: 700; padding: 10px 0 2px; }
dialog .member { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; font-weight: 600; }
.me-tag { font-size: 11px; font-weight: 800; color: var(--accent); margin-left: 4px; }

/* ------------------------------------------------ 기타 */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 12px 18px; font-size: 13.5px; font-weight: 600; z-index: 30;
  max-width: calc(100vw - 32px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.loading { text-align: center; color: var(--muted); padding: 48px 0; font-size: 13px; letter-spacing: 0.04em; }
