/* 작품 상세 · 뷰어 (v2) */

/* 공통 조각(.pill, .avatar.sm, .btn-lg, .empty-state, .toast)은 v2.css 에 있다 */

/* ---------- 작품 상세: 히어로 ---------- */
.series-hero {
  position: relative; display: grid; grid-template-columns: 240px 1fr; gap: 36px; align-items: start;
  margin-top: 16px; padding: 32px; border-radius: var(--radius-l); overflow: hidden; background: var(--bg-elev);
}
.series-hero-bg {
  position: absolute; inset: -60px; background-image: var(--img); background-size: cover; background-position: center;
  filter: blur(48px) saturate(140%); opacity: .35; pointer-events: none;
}
:root[data-theme="light"] .series-hero-bg { opacity: .22; }
.series-cover {
  position: relative; aspect-ratio: 3 / 4; border-radius: var(--radius); overflow: hidden; background: var(--skeleton);
  box-shadow: var(--shadow);
}
.series-cover img { width: 100%; height: 100%; object-fit: cover; }
.series-info { position: relative; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.series-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.series-title { font-size: clamp(26px, 3vw, 36px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; word-break: keep-all; overflow-wrap: anywhere; }
.series-author { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 600; }
.series-stats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--text-3); }
.series-stats li { display: inline-flex; align-items: center; gap: 4px; }
.series-stats strong { color: var(--text); font-weight: 700; }
.series-stats .star { width: 16px; height: 16px; color: var(--gold); }
.series-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.series-synop { color: var(--text-2); font-size: 15px; line-height: 1.7; max-width: 720px; }
.series-synop p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.series-synop.is-open p { -webkit-line-clamp: unset; display: block; }
.synop-more { margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--text-3); }
.synop-more:hover { color: var(--text); }
.series-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.fav-btn .icon { width: 18px; height: 18px; }
.fav-btn[aria-pressed="true"] { background: var(--brand-weak); color: var(--brand); }
.fav-btn[aria-pressed="true"] .icon { fill: currentColor; }
.series-price { font-size: 13px; color: var(--text-3); }
/* 블러 표지 위에서는 보조 글자가 묻히므로 한 단계 진하게 */
.series-hero .series-stats, .series-hero .tag, .series-hero .synop-more, .series-hero .series-price { color: var(--text-2); }

/* 탭 */
.series-tabs {
  position: sticky; top: var(--topbar-h); z-index: 20; display: flex; gap: 4px; margin-top: 24px;
  padding: 8px 0; background: var(--bg); border-bottom: 1px solid var(--line);
}
.series-tabs a { padding: 8px 14px; border-radius: 999px; font-weight: 700; color: var(--text-2); }
.series-tabs a:hover { background: var(--bg-hover); color: var(--text); }
.series-tabs span { color: var(--text-3); font-weight: 600; margin-left: 2px; }
#characters, #episodes, #fans, #comments { scroll-margin-top: calc(var(--topbar-h) + 64px); }
.section-title .count { color: var(--text-3); font-weight: 700; margin-left: 4px; }
.sort-toggle { font-size: 13px; font-weight: 600; color: var(--text-2); padding: 6px 12px; border-radius: 999px; background: var(--bg-elev); }
.sort-toggle:hover { color: var(--text); }

/* 회차 목록 */
.episode-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; }
.episode {
  display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: var(--radius);
}
.episode:hover { background: var(--bg-elev); }
.episode-thumb { flex: none; width: 112px; aspect-ratio: 4 / 3; border-radius: var(--radius-s); overflow: hidden; background: var(--skeleton); }
.episode-thumb img { width: 100%; height: 100%; object-fit: cover; }
.episode-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.episode-title { font-size: 15px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.episode-title strong { font-weight: 800; margin-right: 4px; }
.episode-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); }
.episode-flag:empty { display: none; }
.episode-flag { padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 800; }
.episode-flag.is-new { background: var(--brand); color: var(--brand-ink); }
.episode-flag.is-read { background: var(--bg-elev-2); color: var(--text-2); }
.episode.is-read .episode-title { color: var(--text-3); }
.episode.is-last { box-shadow: inset 3px 0 0 var(--brand); background: var(--bg-elev); }
.episode-go { color: var(--text-3); width: 18px; height: 18px; }

/* ---------- 댓글 ---------- */
.comments { max-width: 860px; }
.comment-form { display: flex; gap: 10px; align-items: flex-start; padding: 14px; border-radius: var(--radius); background: var(--bg-elev); border: 1px solid var(--line); }
.comment-form textarea {
  flex: 1; min-width: 0; min-height: 44px; max-height: 200px; resize: vertical; padding: 10px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; line-height: 1.5;
}
.comment-form textarea:focus { outline: none; border-color: var(--brand); }
.comment-form .btn { align-self: flex-end; }
.comment-login {
  display: block; padding: 16px; text-align: center; border-radius: var(--radius); background: var(--bg-elev);
  border: 1px dashed var(--line); color: var(--text-2); font-weight: 600;
}
.comment-login:hover { color: var(--brand); }
.comment-list { list-style: none; margin: 8px 0 12px; padding: 0; }
.comment { padding: 16px 4px; border-bottom: 1px solid var(--line); }
.comment.is-pinned { background: var(--brand-weak); border-radius: var(--radius); padding: 16px 14px; border-bottom: 0; margin-bottom: 8px; }
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.comment-writer { font-weight: 700; }
.comment-time { margin-left: auto; font-size: 12px; color: var(--text-3); }
.comment-body { margin: 8px 0 10px 36px; font-size: 15px; line-height: 1.6; color: var(--text); overflow-wrap: anywhere; }
.comment-actions { display: flex; align-items: center; gap: 6px; margin-left: 36px; }
.comment-actions .react {
  display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; border-radius: 999px;
  font-size: 13px; color: var(--text-3); background: var(--bg-elev);
}
.comment-actions .react .icon { width: 15px; height: 15px; }
.comment-actions .react:hover { color: var(--text); }
.comment-actions .react[aria-pressed="true"] { color: var(--brand); background: var(--brand-weak); }
.comment-own { margin-left: auto; display: inline-flex; gap: 10px; font-size: 13px; color: var(--text-3); }
.comment-own button:hover { color: var(--text); }
.comment-edit { margin: 8px 0 10px 36px; display: flex; flex-direction: column; gap: 8px; }
.comment-edit textarea { min-height: 80px; padding: 10px 12px; border-radius: var(--radius-s); border: 1px solid var(--brand); background: var(--bg); color: var(--text); font: inherit; resize: vertical; }
.comment-edit div { display: flex; gap: 6px; justify-content: flex-end; }
.comment-empty { padding: 28px 0; text-align: center; color: var(--text-3); }

/* ---------- 뷰어 ---------- */
.is-viewer .sidebar, .is-viewer .topbar, .is-viewer .tabbar, .is-viewer .footer { display: none; }
.is-viewer .main-col, .is-viewer .app[data-sidebar="collapsed"] .main-col { margin-left: 0; }
.viewer-main { padding-bottom: 120px; }
.viewer-bar {
  position: fixed; inset: 0 0 auto 0; z-index: 50; height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--topbar-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
  transition: transform .25s ease;
}
.viewer-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.viewer-title strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.viewer-title span { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-tools { display: flex; gap: 2px; }
.viewer-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.viewer-progress span { display: block; height: 100%; width: 0; background: var(--brand); }
.is-chrome-hidden .viewer-bar { transform: translateY(-100%); }
.is-chrome-hidden .viewer-dock { transform: translate(-50%, 140%); }

.viewer-images { max-width: 720px; margin: 0 auto; padding-top: 56px; background: #fff; }
.viewer-images img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.viewer-images .feed-status { background: var(--bg); padding: 80px 16px; }

.viewer-end { max-width: 760px; margin: 0 auto; padding: 32px 16px 0; display: flex; flex-direction: column; gap: 20px; }
.author-note { display: flex; gap: 12px; padding: 16px; border-radius: var(--radius); background: var(--bg-elev); }
.author-note strong { font-weight: 800; }
.author-note span { color: var(--text-3); font-size: 13px; }
.author-note p { margin-top: 6px; color: var(--text-2); line-height: 1.6; }

.rate-box { padding: 22px 16px; border-radius: var(--radius); background: var(--bg-elev); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.rate-q { font-weight: 700; }
.stars { display: inline-flex; gap: 4px; border-radius: 8px; }
.star { position: relative; width: 40px; height: 40px; color: var(--bg-hover); }
.star .icon { position: absolute; inset: 0; width: 100%; height: 100%; }
.star .fill { color: var(--gold); clip-path: inset(0 100% 0 0); }
.star.is-full .fill { clip-path: inset(0 0 0 0); }
.star.is-half .fill { clip-path: inset(0 50% 0 0); }
.rate-meta { font-size: 13px; color: var(--text-3); }
.rate-meta strong { color: var(--text); }

/* 회차 끝 '이 작품의 AI 캐릭터' (viewer.html) */
.viewer-chars { padding: 18px 16px; border-radius: var(--radius); background: var(--bg-elev); display: flex; flex-direction: column; gap: 12px; }
.viewer-chars-head h2 { font-size: 16px; font-weight: 800; }
.viewer-chars-head p { margin-top: 2px; font-size: 13px; color: var(--text-3); }
.viewer-chars-list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.vc-item { display: flex; align-items: center; gap: 12px; }
.vc-profile { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.vc-img { flex: none; width: 56px; height: 56px; border-radius: 50%; overflow: hidden; background: var(--bg-elev-2); display: grid; place-items: center; }
.vc-img img { width: 100%; height: 100%; object-fit: cover; }
.vc-img .cc-initial { font-size: 22px; }
.vc-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vc-text strong { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-text span { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-profile:hover strong { text-decoration: underline; }
.vc-chat { flex: none; }
.vc-more { align-self: flex-start; display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.vc-more .icon { width: 16px; height: 16px; }

.nav-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.nav-card { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: var(--radius); background: var(--bg-elev); border: 1px solid var(--line); }
.nav-card:hover { border-color: var(--text-3); }
.nav-card-label { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--text-3); font-weight: 600; }
.nav-card-label .icon { width: 16px; height: 16px; }
.nav-card strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-card.is-next { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); text-align: right; align-items: flex-end; }
.nav-card.is-next .nav-card-label { color: rgba(255, 255, 255, .85); }
.viewer-main .comments { max-width: 760px; margin: 40px auto 0; padding: 0 16px; }

.viewer-dock {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  display: flex; gap: 2px; padding: 6px; border-radius: 999px;
  background: var(--topbar-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .25s ease;
}
.dock-btn {
  display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.dock-btn:hover { background: var(--bg-hover); color: var(--text); }
.dock-btn.is-disabled { opacity: .35; pointer-events: none; }
.dock-btn .icon { width: 18px; height: 18px; }
.dock-btn .pause { display: none; }
.dock-btn[aria-pressed="true"] { color: var(--brand); background: var(--brand-weak); }
.dock-btn[aria-pressed="true"] .pause { display: block; }
.dock-btn[aria-pressed="true"] .play { display: none; }

/* ---------- 반응형 ---------- */
@media (max-width: 1023px) {
  .series-hero { grid-template-columns: 1fr; gap: 20px; padding: 20px; }
  .series-cover { width: 46%; max-width: 220px; margin: 0 auto; }
  .series-info { align-items: center; text-align: center; }
  .series-badges, .series-stats, .series-tags, .series-actions { justify-content: center; }
  .series-synop { text-align: left; }
  .episode-list { grid-template-columns: 1fr; }
}
@media (max-width: 599px) {
  .series-hero { margin: 8px calc(var(--gutter) * -1) 0; border-radius: 0; padding: 20px 16px 24px; }
  .series-actions { width: 100%; }
  .series-actions .btn-primary { flex: 1 1 100%; }
  .series-actions .btn-ghost { flex: 1; }
  .series-tabs { top: var(--topbar-h); margin: 16px calc(var(--gutter) * -1) 0; padding: 6px 12px; }
  .episode { padding: 8px 4px; gap: 12px; }
  .episode-thumb { width: 96px; }
  .comment-form { padding: 10px; }
  .comment-form .avatar { display: none; }
  .comment-body, .comment-actions, .comment-edit { margin-left: 0; }
  .viewer-images { padding-top: 52px; }
  .viewer-bar { height: 52px; padding: 0 6px; }
  .viewer-dock { left: 8px; right: 8px; transform: none; justify-content: space-between; border-radius: 18px; bottom: calc(8px + env(safe-area-inset-bottom)); }
  .is-chrome-hidden .viewer-dock { transform: translateY(140%); }
  .dock-btn { flex-direction: column; gap: 2px; height: 48px; padding: 0 8px; font-size: 11px; flex: 1; justify-content: center; }
  .dock-btn > .icon { order: -1; }
  .star { width: 34px; height: 34px; }
  .toast { bottom: 88px; }
}

/* 터치툰: 한 장씩 보기 */
.viewer-images.is-touch {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 56px); min-height: calc(100dvh - 56px); padding-bottom: 72px; background: var(--bg); cursor: pointer;
}
.viewer-images.is-touch img { display: none; width: auto; max-width: 100%; max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); margin: 0 auto; border-radius: 4px; }
.viewer-images.is-touch img.is-current { display: block; }
.touch-nav, .touch-count { display: none; }
.viewer-images.is-touch .touch-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 999px; background: var(--overlay); color: #fff;
}
.viewer-images.is-touch .touch-nav.prev { left: 8px; }
.viewer-images.is-touch .touch-nav.next { right: 8px; }
.viewer-images.is-touch .touch-count {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); display: block; padding: 4px 12px; border-radius: 999px;
  background: var(--overlay); color: #fff; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.is-touch-mode [data-autoscroll] { display: none; }
[data-touch-toggle][aria-pressed="true"] { color: var(--brand); }

/* 열혈 독자 (작품 상세) */
.fans .section-head { align-items: center; flex-wrap: wrap; }
.fans-tabs { margin-bottom: 0; }
.fans-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
@media (max-width: 640px) { .fans-list { grid-template-columns: 1fr; } }
.fan { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--bg-elev); }
.fan-rank { width: 22px; flex: none; text-align: center; font-weight: 800; color: var(--text-3); }
.fan.is-top .fan-rank { color: var(--brand); }
.fan.is-me { box-shadow: inset 0 0 0 1px var(--brand); }
.fan-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.fan-name small { color: var(--text-3); font-weight: 500; }
.fan-score { flex: none; font-size: 13px; color: var(--text-2); }
.fans-me { margin-top: 12px; font-size: 13px; color: var(--text-2); }
.fans-me strong { color: var(--brand); }
.fans-me span { color: var(--text-3); }

/* 댓글이 달린 회차 */
.comment-ep { flex: none; padding: 1px 7px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--text-3); }
