/* =========================================================
   이강토 스토어 — style.css
   모바일 퍼스트 · 브레이크포인트 640 / 768 / 1024
   라이트/다크 테마: <html data-theme="light|dark">
   ========================================================= */

/* ---------- 디자인 토큰 (라이트) ---------- */
:root {
  color-scheme: light;

  --ink: #111111;             /* 본문·주요 버튼 배경 */
  --ink-2: #2b2b2b;
  --on-ink: #ffffff;          /* --ink 위에 올라가는 글자색 */
  --muted: #6d6d6a;
  --muted-2: #9a9a96;
  --line: #e8e8e5;
  --line-strong: #d4d4d0;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-rgb: 255, 255, 255;
  --surface-2: #f1f1ee;

  --accent: #e11d48;          /* 텍스트용 수박 레드 — 흰 배경 대비 4.6:1 */
  --accent-bg: #e11d48;       /* 배지·LIVE 등 채움용 (글자 흰색) */
  --success: #16a34a;
  --warning: #d97706;

  --ticker-bg: #111111;
  --overlay: rgba(17, 17, 17, .55);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 2px rgba(17, 17, 17, .05);
  --shadow: 0 10px 28px rgba(17, 17, 17, .10);
  --shadow-lg: 0 24px 64px rgba(17, 17, 17, .24);

  --header-h: 56px;
  --container: 1200px;

  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui,
          Roboto, "Helvetica Neue", "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR",
          "Malgun Gothic", sans-serif;
}

/* ---------- 디자인 토큰 (다크) ---------- */
html[data-theme="dark"] {
  color-scheme: dark;

  --ink: #f2f2f0;
  --ink-2: #d6d6d2;
  --on-ink: #111111;
  --muted: #a0a09c;
  --muted-2: #74746f;
  --line: #2a2a2e;
  --line-strong: #3b3b40;
  --bg: #0f0f10;
  --surface: #1a1a1d;
  --surface-rgb: 26, 26, 29;
  --surface-2: #26262a;

  --accent: #ff5c7c;          /* 어두운 배경에선 살짝 밝은 레드 */
  --accent-bg: #e11d48;
  --success: #4ade80;
  --warning: #fbbf24;

  --ticker-bg: #000000;
  --overlay: rgba(0, 0, 0, .7);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 10px 28px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
}

/* ---------- 베이스 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
a { color: inherit; }
button, a, input { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* 모달이 열려 있을 때 배경 스크롤 잠금 (script.js 에서 클래스 토글) */
html.modal-open, html.modal-open body { overflow: hidden; }

.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;
}

/* 다크 모드에서 흑백 마스코트가 배경에 묻히지 않도록 살짝 글로우 */
html[data-theme="dark"] .top-image,
html[data-theme="dark"] .modal-logo img,
html[data-theme="dark"] .footer-logo img,
html[data-theme="dark"] .cart-empty-logo {
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, .6));
}
/* 임시 플레이스홀더 이미지는 다크 모드에서 반전 */
html[data-theme="dark"] img[src$="placeholder.svg"] {
  filter: invert(1) hue-rotate(180deg) brightness(.85);
}

/* ---------- 테마 전환 애니메이션 ---------- */
/* View Transitions API: 새 화면 스냅샷을 클릭 지점에서 원형으로 확장 (script.js) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 9999; }

/* View Transitions 미지원 브라우저용 폴백 원 */
.theme-ripple {
  position: fixed;
  z-index: 9999;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
}

/* ---------- 헤더 (sticky) ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  transition: background-color .3s ease, border-color .3s ease;
}

.header-bar {
  height: var(--header-h);
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
}

.top-image-container {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
}

.top-image { width: 100%; height: 100%; object-fit: contain; }

.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.brand-sub {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--accent);
  text-transform: uppercase;
}

.top-nav { display: flex; align-items: center; gap: 2px; }

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  min-width: 44px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .05em;
  text-decoration: none;
  color: var(--ink);
  transition: background-color .2s ease, transform .15s ease;
}
.nav-link svg { width: 22px; height: 22px; flex-shrink: 0; }
.nav-link:hover { background: var(--surface-2); }
.nav-link:active { transform: scale(.94); }

/* 장바구니 개수 배지 */
.cart-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  display: grid;
  place-items: center;
  border: 2px solid var(--surface);
  font-variant-numeric: tabular-nums;
}
.cart-badge[hidden] { display: none; }

/* 테마 토글 (해/달) */
.theme-toggle {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color .2s ease, transform .15s ease;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle:active { transform: scale(.92); }
.theme-toggle svg { width: 22px; height: 22px; grid-area: 1 / 1; transition: transform .5s var(--ease-spring), opacity .25s ease; }
.theme-toggle .icon-sun  { opacity: 0; transform: rotate(-90deg) scale(.6); }
.theme-toggle .icon-moon { opacity: 1; transform: rotate(0) scale(1); }
html[data-theme="dark"] .theme-toggle .icon-sun  { opacity: 1; transform: rotate(0) scale(1); }
html[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(90deg) scale(.6); }

/* 모바일: 아이콘만 노출, 텍스트는 스크린리더용으로 유지 */
@media (max-width: 639px) {
  .nav-link { padding: 0; }
  .nav-link span:not(.cart-badge) {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
}
@media (min-width: 640px) {
  .nav-link { padding: 0 12px; }
  .cart-badge { position: static; margin-left: 2px; border: none; }
}

/* ---------- 라이브 안내 스트립 (티커 + 방송시간) ---------- */
.ticker-wrap {
  display: flex;
  align-items: stretch;
  height: 40px;
  background: var(--ticker-bg);
  color: #fff;
  overflow: hidden;
}

.live-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  background: var(--accent-bg);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}

.ticker-track {
  flex: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 20px, #000 calc(100% - 20px), transparent);
          mask-image: linear-gradient(90deg, transparent, #000 20px, #000 calc(100% - 20px), transparent);
}

.ticker-text {
  flex-shrink: 0;
  white-space: nowrap;
  padding-right: 56px;
  font-size: 14px;
  font-weight: 500;
  animation: marquee 24s linear infinite;
}

@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(.55); opacity: .55; }
}

.schedule-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  text-align: center;
}
.schedule-bar svg { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }

/* ---------- 섹션 헤더 ---------- */
.section-head {
  max-width: var(--container);
  margin: 0 auto;
  padding: 24px 16px 4px;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -.02em;
}
.section-title .live-dot { width: 9px; height: 9px; color: var(--accent); }
.section-desc {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- 카테고리 (sticky 칩) ---------- */
.category-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 90;
  background: var(--bg);
  box-shadow: 0 6px 12px -8px rgba(0, 0, 0, .15);
}

.category-wrap {
  display: flex;
  gap: 8px;
  max-width: var(--container);
  margin: 0 auto;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.category-wrap::-webkit-scrollbar { display: none; }

.category-btn {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  height: 42px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  z-index: 1;
  transition: color .35s ease, transform .2s ease, background-color .35s ease, box-shadow .2s ease;
}
.category-btn::before {
  content: '';
  position: absolute;
  top: var(--y, 50%);
  left: var(--x, 50%);
  width: 0;
  height: 0;
  background: var(--ink);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width .4s ease, height .4s ease;
  z-index: -1;
}
.category-btn:active { transform: scale(.96); }
.category-btn.active { background: var(--ink); color: var(--on-ink); box-shadow: 0 6px 16px rgba(0, 0, 0, .18); }
.category-btn.active::before { display: none; }

@media (hover: hover) {
  .category-btn:hover { color: var(--on-ink); transform: translateY(-2px); }
  .category-btn:hover::before { width: 320px; height: 320px; }
}

@media (min-width: 768px) {
  .category-wrap { gap: 10px; padding: 12px 16px; }
}

/* ---------- 상품 그리드 ---------- */
.container {
  position: relative;               /* 필터 애니메이션용 (script.js) */
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: var(--container);
  margin: 0 auto;
  padding: 12px 16px 56px;
}

@media (min-width: 640px) {
  .container { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding-top: 16px; }
}
@media (min-width: 1024px) {
  .container { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; padding-top: 20px; padding-bottom: 72px; }
}

/* ---------- 상품 카드 ---------- */
.product-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  opacity: 1;
  transform: scale(1);
  transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out), opacity .4s ease, border-color .3s ease, background-color .3s ease;
}
.product-card.hide { opacity: 0; transform: scale(.92); pointer-events: none; }
.product-card.show { opacity: 1; transform: scale(1); }

@media (hover: hover) {
  .product-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: var(--line-strong); }
  .product-card:hover .product-img { transform: scale(1.04); }
}

.card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  overflow: hidden;
}
.product-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s var(--ease-out);
}
.card-img-gradient {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 56px;
  background: linear-gradient(to bottom, rgba(var(--surface-rgb), 0) 0%, var(--surface) 100%);
  pointer-events: none;
}

/* 할인율 배지 — script.js 에서 자동 계산해 삽입 */
.discount-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-bg);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(225, 29, 72, .35);
}

.card-content-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  flex: 1;
  margin-top: -10px;
  padding: 0 14px 14px;
}

.product-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  word-break: keep-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.price {
  display: flex;
  flex-direction: column-reverse;   /* 원가(span)가 위, 할인가(텍스트)가 아래 */
  align-items: flex-start;
  gap: 1px;
  margin: 6px 0 12px;
  line-height: 1.25;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.original-price {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-2);
  text-decoration: line-through;
}

.buy-btn {
  position: relative;
  overflow: hidden;
  margin-top: auto;
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  z-index: 1;
  transition: color .35s ease, transform .15s ease;
}
.buy-btn::before {
  content: '';
  position: absolute;
  top: var(--y, 50%);
  left: var(--x, 50%);
  width: 0;
  height: 0;
  background: var(--accent-bg);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width .4s ease, height .4s ease;
  z-index: -1;
}
.buy-btn:active { transform: scale(.97); }
@media (hover: hover) {
  .buy-btn:hover { color: #fff; }
  .buy-btn:hover::before { width: 440px; height: 440px; }
}

@media (min-width: 640px) {
  .card-content-wrap { padding: 0 16px 16px; }
  .product-title { font-size: 16px; }
  .price { font-size: 19px; }
}

/* ---------- 로그인 모달 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-content {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 40px 28px 28px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  text-align: center;
  transform: translateY(24px) scale(.96);
  opacity: 0;
  transition: transform .45s var(--ease-spring), opacity .3s ease;
}
.modal-overlay.active .modal-content { transform: none; opacity: 1; }

.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}
.close-btn:hover { background: var(--surface-2); color: var(--ink); }

.modal-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto 10px;
}
.modal-logo img { width: 100%; height: 100%; object-fit: contain; }

.modal-content h2 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: .02em;
}
.modal-sub { margin: 0 0 24px; font-size: 14px; color: var(--muted); }

.input-group { margin-bottom: 14px; text-align: left; }
.input-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.input-group input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 16px;               /* iOS 자동 확대 방지 */
  color: var(--ink);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.input-group input::placeholder { color: var(--muted-2); }
.input-group input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(128, 128, 128, .18);
}

.login-submit-btn {
  width: 100%;
  height: 50px;
  margin-top: 6px;
  border: none;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--on-ink);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .2s ease, transform .15s ease;
}
.login-submit-btn:hover { background: var(--ink-2); }
.login-submit-btn:active { transform: scale(.98); }

.modal-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted-2);
}
.modal-links a {
  padding: 6px 2px;
  color: var(--muted);
  text-decoration: none;
  transition: color .2s ease;
}
.modal-links a:hover { color: var(--ink); text-decoration: underline; }

/* ---------- 인증 모달 (로그인 · 회원가입 · 아이디/비밀번호 찾기) ---------- */
.auth-modal {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.auth-modal::-webkit-scrollbar { display: none; }

.auth-back {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}
.auth-back svg { width: 22px; height: 22px; }
.auth-back:hover { background: var(--surface-2); color: var(--ink); }
.auth-back[hidden] { display: none; }

.auth-view[hidden] { display: none; }
.auth-view.is-active { animation: authViewIn .35s var(--ease-out) both; }
@keyframes authViewIn {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: none; }
}
.auth-view[data-view="signup"] h2,
.auth-view[data-view="find"] h2 { font-size: 22px; letter-spacing: -.02em; }

/* 비밀번호 보기/숨기기 */
.input-wrap { position: relative; }
.input-wrap input { padding-right: 48px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 40px;
  height: 40px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s ease, background-color .2s ease;
}
.pw-toggle:hover { color: var(--ink); background: var(--surface-2); }
.pw-toggle svg { width: 20px; height: 20px; grid-area: 1 / 1; }
.pw-toggle .icon-eye-off { display: none; }
.pw-toggle[aria-pressed="true"] .icon-eye { display: none; }
.pw-toggle[aria-pressed="true"] .icon-eye-off { display: block; }

/* 비밀번호 조건 체크리스트 */
.pw-rules {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-2);
}
.pw-rules li { display: inline-flex; align-items: center; gap: 6px; transition: color .25s ease; }
.rule-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: grid;
  place-items: center;
  transition: background-color .25s ease, border-color .25s ease;
}
.rule-icon svg {
  width: 10px;
  height: 10px;
  color: var(--on-ink);
  opacity: 0;
  transform: scale(.4);
  transition: opacity .2s ease, transform .3s var(--ease-spring);
}
.pw-rules li.ok { color: var(--success); }
.pw-rules li.ok .rule-icon { background: var(--success); border-color: var(--success); }
.pw-rules li.ok .rule-icon svg { opacity: 1; transform: scale(1); }
html[data-theme="dark"] .rule-icon svg { color: #0f0f10; }

/* 입력칸 아래 안내/오류 메시지 */
.field-msg {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}
.field-msg svg { width: 14px; height: 14px; flex-shrink: 0; }
.field-msg.is-error { color: var(--accent); }
.field-msg.is-ok { color: var(--success); }
.field-msg.is-hint { color: var(--muted-2); font-weight: 500; }
.input-group.is-error input { border-color: var(--accent); }
.input-group.is-error input:focus { box-shadow: 0 0 0 3px rgba(225, 29, 72, .15); }
.input-group.is-ok input { border-color: var(--success); }
.input-group input[readonly] { background: var(--surface-2); color: var(--muted); }

/* 카카오 로그인 */
.kakao-login-btn {
  width: 100%;
  height: 50px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius);
  background: #fee500;
  color: rgba(0, 0, 0, .85);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: filter .2s ease, transform .15s ease;
}
.kakao-login-btn svg { width: 20px; height: 20px; color: #000; }
.kakao-login-btn:hover { filter: brightness(.95); }
.kakao-login-btn:active { transform: scale(.98); }

/* 찾기 탭 */
.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  border-radius: 12px;
  background: var(--surface-2);
}
.auth-tab {
  flex: 1;
  height: 38px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.auth-tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.auth-panel[hidden] { display: none; }

.find-result {
  margin: 2px 0 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}
.find-result strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: .02em;
  color: var(--ink);
}
.find-result[hidden] { display: none; }
.reset-pw-step[hidden] { display: none; }
.login-submit-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 전화번호 / 이메일 인증 필드 */
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.verify-send-btn {
  flex-shrink: 0;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .15s ease;
}
.verify-send-btn:hover { background: var(--surface-2); }
.verify-send-btn:active { transform: scale(.97); }
.verify-send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.verify-group.is-verified .verify-send-btn,
.verify-group.is-verified .verify-send-btn:disabled {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-color: var(--success);
  color: var(--success);
  background: transparent;
  opacity: 1;
}
.verify-group.is-verified .verify-send-btn svg { width: 16px; height: 16px; }
.verify-group.is-verified .verify-target { border-color: var(--success); }

.verify-code-row { display: flex; gap: 8px; margin-top: 8px; }
.verify-code-row[hidden] { display: none; }
.code-wrap { position: relative; flex: 1; min-width: 0; }
.code-wrap input { width: 100%; padding-right: 64px; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.verify-timer {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.verify-confirm-btn {
  flex-shrink: 0;
  height: 48px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--on-ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .2s ease, transform .15s ease;
}
.verify-confirm-btn:hover { background: var(--ink-2); }
.verify-confirm-btn:active { transform: scale(.97); }
.verify-confirm-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* 안내 메시지 옆 작은 액션 (예: 인증 완료 · 변경) */
.field-msg-action {
  margin-left: auto;
  padding: 2px 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.field-msg-action:hover { color: var(--ink); background: var(--surface-2); }

/* 인증 방법 선택 (전화번호 / 이메일) */
.method-toggle { display: flex; gap: 8px; margin-bottom: 14px; }
.method-option { flex: 1; cursor: pointer; }
.method-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.method-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.method-option input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.method-option input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }

/* 찾기 결과 안의 아이디 목록 */
.find-result .find-id { display: block; margin-top: 4px; font-size: 20px; font-weight: 900; letter-spacing: .02em; color: var(--ink); }

/* ---------- 시트형 모달 공통 (구매 팝업 · 장바구니) ---------- */
/* 모바일: 바텀시트 / 768px 이상: 가운데 다이얼로그 */
.payment-modal-overlay,
.cart-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
}
.payment-modal-overlay.active,
.cart-modal-overlay.active { opacity: 1; visibility: visible; }

.payment-modal-content,
.cart-modal-content {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  width: 100%;
  max-width: 640px;
  max-height: 92dvh;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .3);
  overscroll-behavior: contain;
  transform: translateY(100%);
  transition: transform .55s var(--ease-out);
}
.payment-modal-overlay.active .payment-modal-content,
.cart-modal-overlay.active .cart-modal-content { transform: translateY(0); }

.payment-modal-content {
  padding-bottom: env(safe-area-inset-bottom);
  overflow-y: auto;
  scrollbar-width: none;
}
.payment-modal-content::-webkit-scrollbar { display: none; }

.sheet-handle {
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 10;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .85);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transform: translateX(-50%);
}

@media (min-width: 768px) {
  .payment-modal-overlay,
  .cart-modal-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
  }
  .payment-modal-content,
  .cart-modal-content {
    position: relative;
    bottom: auto;
    max-width: 560px;
    max-height: calc(100dvh - 48px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    transform: translateY(32px) scale(.97);
    opacity: 0;
    transition: transform .45s var(--ease-out), opacity .3s ease;
  }
  .payment-modal-content { padding-bottom: 0; }
  .payment-modal-overlay.active .payment-modal-content,
  .cart-modal-overlay.active .cart-modal-content { transform: none; opacity: 1; }
  .sheet-handle { display: none; }
}

/* ---------- 구매 팝업 ---------- */
/* 스크롤해도 따라오는 닫기 버튼 (음수 마진으로 레이아웃 높이 0) */
.payment-close-btn {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 12px 12px -52px auto;
  border: none;
  border-radius: 50%;
  background: rgba(var(--surface-rgb), .92);
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
  transition: background-color .2s ease, transform .15s ease;
}
.payment-close-btn:hover { background: var(--surface); }
.payment-close-btn:active { transform: scale(.92); }

.popup-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 46dvh;
  background: var(--surface-2);
  overflow: hidden;
}
.popup-img { width: 100%; height: 100%; object-fit: cover; }
.img-gradient {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 120px;
  background: linear-gradient(to bottom, rgba(var(--surface-rgb), 0) 0%, var(--surface) 100%);
  pointer-events: none;
}

.popup-content-wrap {
  position: relative;
  z-index: 1;
  margin-top: -28px;
  padding: 0 20px 20px;
}

.popup-product-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 18px;
  text-align: center;
}
.popup-info { width: 100%; }
.popup-info h3 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.02em;
  word-break: keep-all;
}
.popup-desc { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.6; }

.popup-qty-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 0;
  margin-bottom: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.popup-qty-label-price,
.popup-qty-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.popup-qty-label-price span:first-child,
.popup-qty-control-row > span {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
}
.popup-price {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.01em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.qty-controller {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  overflow: hidden;
}
.qty-controller button {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s ease;
}
.qty-controller button:hover { background: var(--surface-2); }
.qty-controller button:active { background: var(--line); }
.qty-controller input {
  width: 52px;
  height: 44px;
  border: none;
  border-left: 1.5px solid var(--line-strong);
  border-right: 1.5px solid var(--line-strong);
  background: var(--surface);
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  pointer-events: none;
}

.popup-action-btns {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 12px 0 0;
  background: linear-gradient(to top, var(--surface) 75%, rgba(var(--surface-rgb), 0));
}
.popup-action-btns button {
  flex: 1;
  height: 52px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .2s ease, transform .15s ease;
}
.popup-action-btns button:active { transform: scale(.98); }
.cart-btn { background: var(--surface); border: 1.5px solid var(--ink); color: var(--ink); }
.cart-btn:hover { background: var(--surface-2); }
.final-buy-btn { background: var(--ink); border: 1.5px solid var(--ink); color: var(--on-ink); }
.final-buy-btn:hover { background: var(--ink-2); border-color: var(--ink-2); }

@media (min-width: 640px) {
  .popup-content-wrap { padding: 0 32px 28px; }
  .popup-info h3 { font-size: 28px; }
}
@media (min-width: 768px) {
  .popup-img-wrap { max-height: 380px; }
}

/* ---------- 장바구니 모달 ---------- */
.cart-modal-content {
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
  overflow: hidden;
}

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 16px 12px 20px;
}
.cart-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -.02em;
}
.cart-count-label {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 12px;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.cart-close-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}
.cart-close-btn:hover { background: var(--surface-2); color: var(--ink); }

.cart-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 20px;
}

.cart-list { list-style: none; margin: 0; padding: 0; }

.cart-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  align-items: start;
}
.cart-item:first-child { border-top: none; }

.cart-item-img {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.cart-item-info { min-width: 0; }
.cart-item-title {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  word-break: keep-all;
}
.cart-item-unit { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.cart-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.cart-item-qty {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
}
.cart-item-qty button {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s ease;
}
.cart-item-qty button:hover { background: var(--surface-2); }
.cart-item-qty button:disabled { opacity: .4; cursor: not-allowed; }
.cart-item-qty span {
  min-width: 34px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cart-item-price {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.cart-item-remove {
  width: 36px;
  height: 36px;
  margin: -6px -8px 0 0;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted-2);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}
.cart-item-remove:hover { background: var(--surface-2); color: var(--accent); }

.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 0 40px;
}
.cart-empty-logo { width: 96px; height: 96px; object-fit: contain; margin-bottom: 10px; }
.cart-empty-title { margin: 0 0 4px; font-size: 17px; font-weight: 800; }
.cart-empty-desc { margin: 0 0 20px; font-size: 14px; color: var(--muted); }
.cart-empty-btn {
  height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  transition: background-color .2s ease, transform .15s ease;
}
.cart-empty-btn:hover { background: var(--surface-2); }
.cart-empty-btn:active { transform: scale(.97); }

.cart-footer {
  padding: 14px 20px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.cart-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
}
.cart-total-price {
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.cart-checkout-btn {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 12px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .2s ease, transform .15s ease;
}
.cart-checkout-btn:hover { background: var(--ink-2); }
.cart-checkout-btn:active { transform: scale(.98); }

/* 비어 있을 때 / 담겨 있을 때 표시 전환 */
.cart-empty { display: none; }
.cart-modal-content.is-empty .cart-empty { display: flex; }
.cart-modal-content.is-empty .cart-list,
.cart-modal-content.is-empty .cart-footer { display: none; }

@media (min-width: 768px) {
  .cart-modal-content { max-width: 520px; }
  .cart-footer { padding-bottom: 20px; }
}

/* ---------- 토스트 ---------- */
.toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  width: max-content;
  margin: 0 auto;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 12px 14px 12px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transform: translateY(-20px);
  opacity: 0;
  pointer-events: none;
  transition: transform .4s var(--ease-out), opacity .25s ease;
}
.toast.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
.toast-icon { display: grid; place-items: center; }
.toast-icon svg { width: 20px; height: 20px; }
.toast.success .toast-icon { color: var(--success); }
.toast.warning .toast-icon { color: var(--warning); }
.toast-msg { white-space: normal; line-height: 1.4; }
.toast-action {
  margin-left: 4px;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: rgba(128, 128, 128, .25);
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .2s ease;
}
.toast-action:hover { background: rgba(128, 128, 128, .4); }
.toast-action[hidden] { display: none; }

/* ---------- 푸터 ---------- */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 28px 16px calc(28px + env(safe-area-inset-bottom));
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  max-width: var(--container);
  margin: 0 auto;
  font-size: 13px;
  color: var(--muted);
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--ink);
}
.footer-logo { width: 30px; height: 30px; }
.footer-logo img { width: 100%; height: 100%; object-fit: contain; }
.footer-links { display: flex; gap: 16px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--ink); text-decoration: underline; }
.footer-copy { width: 100%; font-size: 12px; color: var(--muted-2); }

@media (min-width: 768px) {
  .footer-copy { width: auto; order: 3; }
}

/* ---------- 모션 최소화 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
  .ticker-text { animation: none; white-space: normal; padding-right: 0; font-size: 13px; }
  .ticker-text[aria-hidden="true"] { display: none; }
}
