/* 이 페이지만 Toss 톤 팔레트(진한 남색 잉크 + 파랑/빨강)를 쓴다.
   공유 --ink/--brand/--muted 등을 여기서 덮어쓰면 같은 페이지에 함께 로드되는
   disclosure.css 같은 공유 컴포넌트의 색까지 바뀌어 버리므로, 이름이 겹치지
   않는 --feed- 접두어 변수로 따로 둔다. */
:root {
  --bg: #f2f4f6;
  --feed-ink: #191f28;
  --feed-ink-2: #333d4b;
  --feed-muted: #8b95a1;
  --feed-brand: #0a7a52;
  --feed-brand-hover: #076043;
  --feed-danger: #f04452;
  /* .cat-btn.active처럼 "잉크색을 배경으로 채운" 반전 필 전용 토큰.
     --feed-ink는 다크 모드에서 밝은 글자색으로 뒤집히므로 배경엔 못 쓴다 —
     반전 필은 라이트/다크 모두에서 배경과 글자색이 같이 뒤집혀야 한다. */
  --feed-active-bg: #191f28;
  --feed-active-text: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --feed-ink: #f1f5f9;
    --feed-ink-2: #cbd5e1;
    --feed-muted: #94a3b8;
    --feed-brand: #22c58a;
    --feed-brand-hover: #4ade9a;
    --feed-danger: #f87171;
    --feed-active-bg: #f1f5f9;
    --feed-active-text: #0f172a;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background-color: var(--bg); color: var(--feed-ink); padding: 20px; }
.container { max-width: 1000px; margin: 0 auto; }

/* 헤더 영역 */
header { display: flex; justify-content: space-between; align-items: center; background: transparent; margin-bottom: 20px; }
.logo-area h1 { font-size: 22px; color: var(--feed-ink); display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 800; }
.logo-mark { width: 24px; height: 24px; flex-shrink: 0; }
.logo-mark .a { fill: var(--feed-brand); }
.logo-mark .b { fill: var(--feed-ink); }

/* 아이콘 시스템 (Lucide, MIT). <symbol> 스프라이트는 body 시작 부분에 두었다. */
.icon { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn { padding: 10px 18px; min-height: 44px; line-height: 1; border-radius: 8px; font-weight: 600; font-size: 14px; text-decoration: none; border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background 0.2s; }
.btn-primary { background: var(--feed-brand); color: #ffffff; }
.btn-primary:hover { background: var(--feed-brand-hover); }

/* 환영 헤더 */
.welcome-header { font-size: 20px; font-weight: 700; color: var(--feed-ink); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* 피드 탭 (전체 / 구독). 기본 숨김이며 index.js가 로그인 상태에 따라
   .style.display를 직접 토글한다(CSP style-src 제약 없음). */
.feed-tab-group { display: none; gap: 10px; margin-bottom: 16px; }
.feed-tab-btn { flex: 1; padding: 12px; border: none; border-radius: 12px; font-weight: 700; font-size: 15px; cursor: pointer; background: var(--card); color: var(--feed-muted); box-shadow: 0 2px 8px rgba(0,0,0,0.02); }
.feed-tab-btn.active { background: var(--feed-brand); color: #ffffff; }

/* 💡 검색 및 필터 영역 (최근 검색어 레이어 지원) */
.filter-section { margin-bottom: 20px; display: flex; flex-direction: column; gap: 12px; position: relative; }
.search-row { display: flex; gap: 10px; position: relative; }
.search-input-wrapper { flex: 1; position: relative; }
.search-input { width: 100%; padding: 14px 16px; border: none; border-radius: 12px; font-size: 16px; outline: none; background: var(--card); box-shadow: 0 2px 8px rgba(0,0,0,0.02); }
.search-input::placeholder { color: #b0b8c1; }
.sort-select { padding: 14px 16px; border: none; border-radius: 12px; font-size: 16px; background: var(--card); font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,0.02); cursor: pointer; color: #4e5968; }

/* 💡 최근 검색어 드롭다운 패널 */
.recent-search-panel { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--card); border-radius: 14px; padding: 16px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 100; display: none; }
.recent-search-header { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; color: var(--feed-muted); margin-bottom: 10px; }
.recent-search-label { display: inline-flex; align-items: center; gap: 4px; }
.recent-clear-btn { background: none; border: none; color: var(--feed-danger); font-size: 12px; font-weight: 600; cursor: pointer; }
.recent-chips-wrapper { display: flex; gap: 6px; flex-wrap: wrap; }
.recent-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--bg); padding: 6px 12px; border-radius: 16px; font-size: 13px; color: var(--feed-ink-2); font-weight: 500; cursor: pointer; }
.recent-chip-delete { font-size: 11px; color: var(--feed-muted); font-weight: bold; margin-left: 2px; }
.recent-empty { font-size: 12px; color: var(--feed-muted); }

/* 💡 스티키 카테고리 필터 바 (화면 상단 고정 + 가로 스크롤) */
.sticky-category-wrapper { position: sticky; top: 0; z-index: 90; background: var(--bg); padding: 8px 0 12px 0; margin-bottom: 8px; }
.category-group { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; padding-bottom: 4px; }
.category-group::-webkit-scrollbar { display: none; }
.cat-btn { padding: 9px 18px; min-height: 44px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; background: var(--card); border-radius: 20px; font-size: 14px; color: #4e5968; cursor: pointer; font-weight: 600; box-shadow: 0 2px 4px rgba(0,0,0,0.02); white-space: nowrap; flex-shrink: 0; }
.cat-btn .icon { width: 15px; height: 15px; }
.cat-btn.active { background: var(--feed-active-bg); color: var(--feed-active-text); }

/* 💡 활성 필터 칩 표시 영역. index.js가 필터 개수에 따라 .style.display를 직접 토글한다. */
.active-filter-chips { display: none; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.active-filter-label { font-size: 13px; font-weight: 700; color: var(--feed-muted); }
.filter-tag-container { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-tag-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--feed-brand); color: white; padding: 5px 12px; border-radius: 16px; font-size: 12px; font-weight: 600; }
.filter-tag-close { cursor: pointer; font-weight: bold; font-size: 12px; }

/* 상품 카드 그리드 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px; }
.card { background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: 0 4px 16px rgba(0,0,0,0.04); position: relative; transition: transform 0.2s, box-shadow 0.2s; cursor: pointer; border: 1px solid rgba(0,0,0,0.02); display: flex; flex-direction: column; }
.card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.card-img-wrapper { position: relative; width: 100%; height: 200px; }
.card-img { width: 100%; height: 100%; object-fit: contain; background: var(--surface-muted); }
.bookmark-btn { position: absolute; bottom: 12px; right: 12px; background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(4px); border: none; border-radius: 50%; width: 44px; height: 44px; cursor: pointer; color: #ffffff; display: flex; align-items: center; justify-content: center; z-index: 10; transition: transform 0.1s; }
.bookmark-btn:active { transform: scale(0.9); }
.bookmark-btn .icon { width: 20px; height: 20px; }
.bookmark-btn.bookmarked { color: #ef4444; }
.bookmark-btn.bookmarked .icon { fill: currentColor; animation: heartPop 0.3s ease; }
@keyframes heartPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .bookmark-btn.bookmarked .icon { animation: none; }
}
.card-content { padding: 16px; display: flex; flex-direction: column; flex: 1; }
.card-title { font-size: 16px; font-weight: 600; margin: 0 0 6px 0; color: var(--feed-ink-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-desc { font-size: 13px; color: var(--feed-muted); margin-bottom: 12px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.card-price { font-size: 17px; font-weight: 700; color: var(--feed-brand); margin-top: auto; }
.empty-msg { grid-column: 1 / -1; text-align: center; padding: 60px; color: var(--feed-muted); font-weight: 600; }
.empty-state { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 60px 20px; color: var(--feed-muted); text-align: center; font-weight: 600; }
.empty-state .icon { width: 36px; height: 36px; opacity: 0.45; }
.empty-state p { margin: 0; }

/* 크리에이터 칩 v2 */
.creator-chip { display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--bg); padding: 6px 12px 6px 6px; border-radius: 24px; cursor: pointer; transition: background 0.2s; margin-top: 12px; }
.creator-chip:hover { background: #e5e8eb; }
.chip-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.chip-avatar-placeholder { width: 24px; height: 24px; border-radius: 50%; background: var(--feed-brand); color: #ffffff; font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.chip-brand-text { font-size: 13px; font-weight: 600; color: var(--feed-ink-2); }
.chip-arrow { font-size: 10px; color: var(--feed-muted); font-weight: bold; margin-left: 2px; }
.creator-chip-left { display: flex; align-items: center; gap: 8px; }

/* 노출 기간 배지 (등록된 상품 카드) */
.period-badge { font-size: 11px; color: var(--ink-soft); background: var(--surface-muted); border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px; margin-top: 8px; line-height: 1.4; display: flex; flex-direction: column; gap: 3px; }
.period-row { display: inline-flex; align-items: center; gap: 4px; }
