/* ================================================================
   테마 변수 — 기본은 다크, html[data-theme="light"] 이면 라이트
   ================================================================ */
:root {
  --bg: #0b0b0f;          /* 앱 배경 */
  --bg2: #15151b;         /* 썸네일 등 보조 배경 */
  --page: #16161c;        /* PC 에서 휴대폰 프레임 바깥 */
  --fg: #ffffff;          /* 기본 글자 */
  --fg2: rgba(255,255,255,.85);
  --fg3: rgba(255,255,255,.6);
  --muted: #8b8b97;
  --line: #1f1f27;
  --glass: rgba(255,255,255,.12);   /* 반투명 버튼 */
  --glass-on: #ffffff;
  --glass-on-fg: #000000;
  --topbar: linear-gradient(rgba(0,0,0,.55), transparent);
  --btn-bg: #ffffff;
  --btn-fg: #000000;
  --ghost: rgba(255,255,255,.1);
  --outline: rgba(255,255,255,.14);
  --dot: rgba(255,255,255,.35);
  --dot-on: #ffffff;
  --tint: 38%;            /* 슬라이드 배경에 섞을 주제색 비율 */
  --tag-mix: var(--fg);
  --frame-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 1px #26262e;
  --toast-bg: rgba(255,255,255,.95);
  --toast-fg: #000;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --warn-bg: rgba(245,158,11,.16);
  --warn-fg: #fbbf24;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f6f6f8;
  --bg2: #e6e6ec;
  --page: #e4e4ea;
  --fg: #111118;
  --fg2: rgba(17,17,24,.82);
  --fg3: rgba(17,17,24,.55);
  --muted: #6e6e7a;
  --line: #e3e3ea;
  --glass: rgba(17,17,24,.07);
  --glass-on: #111118;
  --glass-on-fg: #ffffff;
  --topbar: linear-gradient(rgba(246,246,248,.9), transparent);
  --btn-bg: #111118;
  --btn-fg: #ffffff;
  --ghost: rgba(17,17,24,.06);
  --outline: rgba(17,17,24,.12);
  --dot: rgba(17,17,24,.2);
  --dot-on: #111118;
  --tint: 22%;
  --tag-mix: #000000;
  --frame-shadow: 0 30px 80px rgba(0,0,0,.18), 0 0 0 1px #d6d6de;
  --toast-bg: rgba(17,17,24,.92);
  --toast-fg: #fff;
  --warn-bg: rgba(245,158,11,.14);
  --warn-fg: #b45309;
  color-scheme: light;
}

/* 이미지가 깔린 표지는 테마와 상관없이 어두운 오버레이 + 흰 글자 */
.has-img {
  --fg: #ffffff;
  --fg2: rgba(255,255,255,.85);
  --fg3: rgba(255,255,255,.6);
}

/* 이미지 표지를 보고 있을 때: 상단 바·위치 막대·PC 버튼을 어두운 스타일로 */
.over-img .topbar, .over-img .rail, .over-img .vnav {
  --fg: #ffffff;
  --glass: rgba(255,255,255,.16);
  --glass-on: #ffffff;
  --glass-on-fg: #000000;
  --topbar: linear-gradient(rgba(0,0,0,.55), transparent);
  --dot: rgba(255,255,255,.35);
  --dot-on: #ffffff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", Pretendard, "Malgun Gothic", "Noto Sans KR", sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- 휴대폰 프레임: PC 에서도 같은 크기 ---------- */
.phone {
  position: relative;
  width: min(100vw, 430px);
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
}
@media (min-width: 520px) {
  body { display: flex; align-items: center; justify-content: center; background: var(--page); }
  .phone { height: min(100dvh - 32px, 932px); border-radius: 28px; box-shadow: var(--frame-shadow); }
}

.view { position: absolute; inset: 0; }
.hidden { display: none !important; }

/* ---------- 상단 바 ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 14px 24px;
  background: var(--topbar);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: var(--glass); color: var(--fg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.icon-btn.on { background: var(--glass-on); color: var(--glass-on-fg); }

.chip {
  border: 0; border-radius: 999px; padding: 9px 16px;
  font-size: 14px; font-weight: 700;
  background: var(--glass); color: var(--fg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.chip::after { content: " ▾"; opacity: .6; font-size: 11px; }

/* ---------- 피드: 세로 = 다음 글 ---------- */
.feed {
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar, .slides::-webkit-scrollbar { display: none; }

.card {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* ---------- 카드 안: 가로 = 슬라이드 ---------- */
.slides {
  display: flex;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: start;
  display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--safe-top) + 88px) 28px calc(var(--safe-bottom) + 84px);
  color: var(--fg);
  background:
    radial-gradient(130% 70% at 0% 0%, color-mix(in srgb, var(--c) var(--tint), transparent), transparent 62%),
    radial-gradient(90% 60% at 100% 100%, color-mix(in srgb, var(--c) calc(var(--tint) / 2), transparent), transparent 70%),
    var(--bg);
}

/* 표지 */
.cover {
  justify-content: flex-end;
  background-size: cover;
  background-position: center;
}
.badge {
  align-self: flex-start;
  background: var(--c); color: #fff;
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
  padding: 5px 11px; border-radius: 999px;
}
.meta { font-size: 13px; color: var(--fg3); margin: 12px 0 0; }
.cover h2 {
  font-size: 30px; line-height: 1.28; font-weight: 800; letter-spacing: -.02em;
  margin: 10px 0 0; word-break: keep-all;
}
.hook { font-size: 17px; line-height: 1.5; color: var(--fg2); margin: 14px 0 0; word-break: keep-all; }
.hints { display: flex; flex-direction: column; gap: 7px; margin-top: 26px; }
.hints span { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg3); }
.hints svg { flex: 0 0 auto; opacity: .85; }

/* 본문 슬라이드 */
.num { font-size: 13px; font-weight: 800; color: var(--c); letter-spacing: .08em; }
.slide h3 { font-size: 26px; line-height: 1.3; font-weight: 800; margin: 12px 0 18px; word-break: keep-all; letter-spacing: -.01em; }
.slide p.body { font-size: 19px; line-height: 1.7; color: var(--fg2); margin: 0; word-break: keep-all; }

/* 마지막 슬라이드 */
.end .orig { font-size: 15px; color: var(--fg2); line-height: 1.5; margin: 0 0 24px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 28px; }
.tag {
  font-size: 13px; font-weight: 700;
  color: color-mix(in srgb, var(--c) 75%, var(--tag-mix));
  background: color-mix(in srgb, var(--c) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  padding: 5px 10px; border-radius: 999px;
}
.btn {
  display: block; text-align: center; text-decoration: none;
  padding: 15px; border-radius: 14px; margin-top: 10px;
  font-weight: 800; font-size: 16px;
  background: var(--btn-bg); color: var(--btn-fg);
}
.btn.ghost { background: var(--ghost); color: var(--fg); }
.stats { font-size: 13px; color: var(--muted); margin-top: 18px; text-align: center; }

/* 슬라이드 점 */
.dots {
  position: absolute; left: 0; right: 0;
  bottom: calc(var(--safe-bottom) + 32px);
  display: flex; justify-content: center; gap: 6px;
  pointer-events: none;
}
.dot { width: 6px; height: 6px; border-radius: 3px; background: var(--dot); transition: width .25s, background .25s; }
.dot.on { width: 20px; background: var(--dot-on); }
.card.on-img .dot { background: rgba(255,255,255,.4); }
.card.on-img .dot.on { background: #fff; }

/* 공유 버튼 (카드 오른쪽 아래) */
.share-btn {
  position: absolute; right: 14px; bottom: calc(var(--safe-bottom) + 18px); z-index: 5;
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: var(--glass); color: var(--fg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.card.on-img .share-btn { background: rgba(255,255,255,.16); color: #fff; }
.btn.share-wide { width: 100%; border: 0; font: inherit; font-weight: 800; font-size: 16px; cursor: pointer; }

/* PC: 마우스로 끌어서 넘기기 */
@media (hover: hover) and (pointer: fine) {
  .feed { cursor: grab; }
}
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none !important; }

/* PC: 좌우 화살표 */
.nav {
  display: none;
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%; border: 0;
  background: var(--glass); color: var(--fg); backdrop-filter: blur(8px);
  font-size: 20px; line-height: 1;
}
.nav.prev { left: 10px; }
.nav.next { right: 10px; }
@media (hover: hover) {
  .nav { display: grid; place-items: center; opacity: 0; transition: opacity .2s; }
  .card:hover .nav { opacity: 1; }
  .nav[disabled] { opacity: 0 !important; }
}

/* 마지막 슬라이드: 다음 소식으로 */
.next-up {
  display: flex; align-items: center; gap: 12px; width: 100%;
  margin-top: 22px; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--outline); background: var(--ghost); color: var(--fg);
  text-align: left;
}
.next-up .lbl { font-size: 12px; color: var(--muted); font-weight: 700; }
.next-up .nt { font-size: 14px; font-weight: 700; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.next-up .txt { flex: 1; min-width: 0; }
.next-up svg { flex: 0 0 auto; animation: nudge 1.6s ease-in-out infinite; }
.last-note { font-size: 13px; color: var(--muted); text-align: center; margin-top: 22px; }

/* 오른쪽 세로 위치 막대 */
.rail {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 72px; border-radius: 2px;
  background: var(--dot); z-index: 6; pointer-events: none;
}
.rail-thumb {
  position: absolute; left: 0; top: 0; width: 3px; height: 18px; border-radius: 2px;
  background: var(--dot-on); transition: top .25s ease;
}

/* PC: 세로 이동 버튼 */
.vnav { display: none; }
@media (hover: hover) {
  .vnav {
    display: flex; flex-direction: column; gap: 8px;
    position: absolute; right: 16px; bottom: calc(var(--safe-bottom) + 70px); z-index: 6;
  }
  .vnav .icon-btn { width: 36px; height: 36px; }
  .vnav .icon-btn[disabled] { opacity: .3; cursor: default; }
}

/* 첫 방문 안내 */
.coach {
  position: absolute; left: 50%; top: 36%;
  transform: translateX(-50%); z-index: 7;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(0,0,0,.6); color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 12px 20px 14px; border-radius: 18px;
  font-size: 14px; font-weight: 700; pointer-events: none;
  animation: bob 1.4s ease-in-out infinite;
  transition: opacity .3s;
}
.coach.fade { opacity: 0; }
@keyframes bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -8px); } }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }

/* 빈 화면 */
.empty {
  height: 100%; display: grid; place-items: center; text-align: center;
  color: var(--muted); font-size: 15px; line-height: 1.7; padding: 0 40px;
}

/* ---------- 목록 ---------- */
.list-view { display: flex; flex-direction: column; background: var(--bg); }
.list-head {
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-top) + 14px) 16px 10px;
}
.list-head h1 { flex: 1; display: flex; align-items: center; gap: 9px; font-size: 22px; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; }

.filters {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 6px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: 0 0 auto;
  border: 1px solid var(--outline); background: transparent; color: var(--fg2);
  border-radius: 999px; padding: 8px 15px; font-size: 14px; font-weight: 600;
}
.filter .sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--c); vertical-align: 1px; }
.filter.on { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }

.list-scroll { flex: 1; overflow-y: auto; }
.list { list-style: none; margin: 0; padding: 0 16px; }
.row {
  display: flex; gap: 14px; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.row:active { opacity: .7; }
.thumb {
  flex: 0 0 72px; height: 96px; border-radius: 12px;
  background-size: cover; background-position: center;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800; color: #fff;
}
.row .info { min-width: 0; }
.row .badge { font-size: 11px; padding: 3px 8px; }
.row .t {
  font-size: 15px; font-weight: 700; line-height: 1.4; margin: 7px 0 5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  word-break: keep-all;
}
.row .m { font-size: 12px; color: var(--muted); }
.sentinel { height: 40px; }
.list-empty { color: var(--muted); text-align: center; padding: 60px 0; font-size: 14px; }

/* ---------- 수집 중단 안내 ---------- */
.notice {
  display: flex; gap: 8px; align-items: flex-start;
  margin: 0 16px 10px; padding: 10px 14px; border-radius: 12px;
  background: var(--warn-bg); color: var(--warn-fg);
  font-size: 13px; font-weight: 600; line-height: 1.5;
}
.notice::before { content: "⚠"; flex: 0 0 auto; }
.notice.floating {
  position: absolute; left: 14px; right: 14px; margin: 0;
  top: calc(var(--safe-top) + 66px); z-index: 9;
  background: color-mix(in srgb, var(--bg) 70%, #f59e0b);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
}

/* ---------- 토스트 ---------- */
.toast {
  position: absolute; left: 50%; bottom: calc(var(--safe-bottom) + 70px);
  transform: translate(-50%, 20px); opacity: 0;
  background: var(--toast-bg); color: var(--toast-fg);
  font-size: 14px; font-weight: 600; line-height: 1.5;
  padding: 11px 16px; border-radius: 12px;
  width: max-content; max-width: 86%; text-align: center;
  transition: opacity .25s, transform .25s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
