:root {
  --bg: #0a0810;
  --bg-elev: #14111d;
  --bg-card: #17131f;
  --bg-hover: #201a2e;
  --line: #272138;
  --line-soft: #201b30;
  --text: #f1eef8;
  --muted: #968dae;
  --accent: #b99be8;
  --accent-strong: #8b6fc7;
  --accent-grad: linear-gradient(135deg, #9a7be0 0%, #7d5bc6 100%);
  --danger: #e8788f;
  --nav-h: 60px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, .38);
  --shadow-pop: 0 10px 34px rgba(0, 0, 0, .5);
  --ease: .18s cubic-bezier(.4, 0, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  overscroll-behavior-y: none;
}

body { -webkit-tap-highlight-color: transparent; }

a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; }
.hidden { display: none !important; }

/* ── 레이아웃 ───────────────────────────────────── */

.view {
  padding: calc(52px + var(--safe-t)) 0 calc(var(--nav-h) + var(--safe-b) + 16px);
  min-height: 100vh;
}
/* 상단 바를 감춘 화면(작품 상세, 재생)은 위 여백만 없앤다.
   아래 탭이 남아 있는 경우가 있어 아래 여백은 그대로 둔다. */
.view.plain { padding-top: 0; }

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: calc(52px + var(--safe-t));
  padding: var(--safe-t) 10px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(12, 10, 17, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}
.topbar-logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  flex: 0 0 auto;
  margin-right: 2px;
}
.topbar-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-back, .topbar-action {
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--ease);
}
.topbar-back svg, .topbar-action svg { width: 23px; height: 23px; }
.topbar-action { width: auto; padding: 0 12px; font-size: 14px; font-weight: 700; gap: 6px; }
.topbar-back:hover, .topbar-action:hover { background: var(--bg-hover); }

.nav {
  position: fixed;
  inset: auto 0 0 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: rgba(10, 8, 16, 0.9);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  z-index: 40;
}
.nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  transition: color var(--ease);
}
.nav-ico { display: grid; place-items: center; width: 25px; height: 25px; }
.nav-ico svg { width: 25px; height: 25px; transition: transform var(--ease); }
.nav a.active { color: var(--accent); }
.nav a.active .nav-ico svg { transform: translateY(-1px) scale(1.06); }

/* ── 섹션 / 카드 ────────────────────────────────── */

.section { margin: 22px 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 14px 10px;
}
.section-head h2 {
  margin: 0;
  font-size: 17.5px;
  font-weight: 800;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.section-head h2::before {
  content: "";
  width: 4px;
  height: 17px;
  border-radius: 3px;
  background: var(--accent-grad);
}
.section-head a { font-size: 13px; color: var(--muted); transition: color var(--ease); }
@media (hover: hover) { .section-head a:hover { color: var(--accent); } }
.section-note { font-size: 11.5px; color: var(--muted); }

/* ── 탐색 (년도 / 분기 / 장르) ──────────────────── */

.browse-head {
  position: sticky;
  top: calc(52px + var(--safe-t));
  z-index: 20;
  background: rgba(12, 10, 17, .94);
  backdrop-filter: blur(12px);
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--line);
}

.pill-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 14px 8px;
  scrollbar-width: none;
}
.pill-row::-webkit-scrollbar { display: none; }
.pill-row:last-child { padding-bottom: 2px; }

.pill-btn {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.pill-btn.sm { padding: 6px 12px; font-size: 12.5px; }
.pill-btn { transition: background var(--ease), border-color var(--ease), color var(--ease); }
@media (hover: hover) { .pill-btn:hover { border-color: var(--accent-strong); color: var(--text); } }
.pill-btn.active {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 3px 12px rgba(125, 91, 198, .4);
}
.pill-btn b {
  display: inline-block;
  margin-left: 5px;
  font-size: 11px;
  font-weight: 700;
  opacity: .72;
}
.pill-note { padding: 4px 14px 6px; font-size: 12px; color: var(--muted); }
.pill-spacer { flex: 1 0 8px; }
.genre-btn { display: inline-flex; align-items: center; gap: 3px; }
.genre-btn svg { width: 15px; height: 15px; }

/* 장르 선택 팝업 */
.gp-overlay {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  padding: 24px 18px;
  background: rgba(6,5,10,.72); backdrop-filter: blur(6px);
  animation: dt-fade .16s ease;
}
.gp-card {
  width: 100%; max-width: 560px; max-height: 78vh;
  display: flex; flex-direction: column;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
  overflow: hidden; animation: dt-pop .2s cubic-bezier(.2,.7,.3,1);
}
.gp-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; font-size: 16px; font-weight: 800; border-bottom: 1px solid var(--line-soft); }
.gp-close { background: none; border: 0; color: var(--muted); width: 30px; height: 30px; display: grid; place-items: center; cursor: pointer; }
.gp-close svg { width: 20px; height: 20px; }
.gp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; padding: 16px 18px 20px; overflow-y: auto; }
.gp-item {
  min-height: 42px;
  padding: 9px 8px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--bg-card); border: 1px solid var(--line);
  color: var(--text); font-size: 12.5px; font-weight: 600; cursor: pointer;
  line-height: 1.25; word-break: keep-all; text-align: center;
  transition: background var(--ease), border-color var(--ease);
}
@media (hover: hover) { .gp-item:hover { border-color: var(--accent-strong); } }
.gp-item.active { background: var(--accent-grad); border-color: transparent; color: #fff; font-weight: 800; }

.rail {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 0 14px 4px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail > * { flex: 0 0 auto; scroll-snap-align: start; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 14px 10px;
  padding: 0 14px;
}

.card { width: 100%; cursor: pointer; }
.rail .card { width: 128px; }
.card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  transition: transform var(--ease), box-shadow var(--ease);
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease; }
.card:active .card-thumb { transform: scale(.975); }
@media (hover: hover) {
  .card { transition: transform var(--ease); }
  .card:hover { transform: translateY(-4px); }
  .card:hover .card-thumb { box-shadow: var(--shadow-pop); }
  .card:hover .card-thumb img { transform: scale(1.06); }
  .card:hover .card-title { color: var(--accent); }
}
/* 접었다 펼치기 (모바일 보던 작품) */
.grid.collapsible.collapsed > .card:nth-child(n+7) { display: none; }
.more-btn {
  display: block; margin: 14px auto 0; padding: 9px 22px;
  border-radius: 999px; background: var(--bg-card); border: 1px solid var(--line);
  color: var(--text); font-size: 13px; font-weight: 700; cursor: pointer;
}
.more-btn span { color: var(--muted); }
@media (min-width: 760px) {
  .grid.collapsible.collapsed > .card:nth-child(n+7) { display: block; }
  .more-btn { display: none; }
}

.card-title {
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.35;
  font-weight: 500;
  transition: color var(--ease);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-badge {
  position: absolute;
  left: 7px;
  bottom: 7px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(10, 8, 16, .72);
  backdrop-filter: blur(6px);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .01em;
}

/* 새 화가 올라온 작품 */
.badge-new {
  position: absolute;
  top: 7px;
  left: 7px;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--accent-grad);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .05em;
  box-shadow: 0 3px 10px rgba(125, 91, 198, .5);
}

.card-sub {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 소스 사이트에 아직 없는 편성표 항목 */
.card-dim { opacity: .48; }

/* 이어보기 삭제(휴지통) 버튼 — 모바일 상시, PC 호버 */
.card-del {
  position: absolute; top: 6px; right: 6px; z-index: 3;
  width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: rgba(10, 8, 16, .68); backdrop-filter: blur(4px);
  color: #fff; display: grid; place-items: center; cursor: pointer;
  opacity: 0; transition: opacity var(--ease), background var(--ease);
}
.card-del svg { width: 16px; height: 16px; }
@media (hover: hover) {
  .card:hover .card-del { opacity: 1; }
  .card-del:hover { background: var(--danger); color: #fff; }
}
@media (hover: none) { .card-del { opacity: 1; background: rgba(10, 8, 16, .55); } }

.card-empty {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  color: var(--muted);
  background: repeating-linear-gradient(-45deg, #191527, #191527 8px, #1d1830 8px, #1d1830 16px);
}

/* 요일 탭 */
.day-tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 14px 12px;
  scrollbar-width: none;
}
.day-tabs::-webkit-scrollbar { display: none; }

.day-tab {
  position: relative;
  flex: 0 0 auto;
  min-width: 46px;
  padding: 9px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.day-tab { transition: background var(--ease), color var(--ease), border-color var(--ease); }
.day-tab.active {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 3px 12px rgba(125, 91, 198, .4);
}
.day-tab i {
  display: block;
  font-style: normal;
  font-size: 9.5px;
  font-weight: 600;
  opacity: .85;
  margin-top: 1px;
}

/* 편성표 보기 토글 (한눈에 / 요일별) */
.sched-toggle { display: inline-flex; gap: 4px; margin: 0 14px 12px; padding: 3px; background: var(--bg-card); border: 1px solid var(--line); border-radius: 999px; }
.sched-mode { padding: 6px 15px; border: 0; border-radius: 999px; background: none; color: var(--muted); font-size: 12.5px; font-weight: 700; cursor: pointer; transition: background var(--ease), color var(--ease); }
.sched-mode.active { background: var(--accent-grad); color: #fff; }

/* 기본 = 한눈에. 모바일은 요일별 가로 레일을 세로로 쌓는다. */
.day-mobile { display: none; }
.day-columns { display: flex; flex-direction: column; gap: 22px; padding: 0 14px; }
.day-columns .day-col-head { font-size: 15px; font-weight: 800; padding: 0 2px 10px; display: flex; align-items: center; gap: 6px; }
.day-columns .day-col.active .day-col-head { color: var(--accent); }
.day-columns .day-col-head i { font-style: normal; font-size: 10px; font-weight: 700; color: var(--accent); }
.day-col-list { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.day-col-list::-webkit-scrollbar { display: none; }
.day-col-list .card { flex: 0 0 108px; width: 108px; }
.day-col-empty { font-size: 12px; color: var(--muted); padding: 8px 2px; }

/* 요일별 모드: 탭 + 단일 그리드 (모바일·PC 공통) */
#schedule-body.mode-byday .day-mobile { display: block; }
#schedule-body.mode-byday .day-columns { display: none; }

/* 이어보기 카드 (가로형) */
.wide { width: 232px; }
.wide .card-thumb { aspect-ratio: 16 / 9; }
.wide-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.progress-bar {
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: rgba(255, 255, 255, .22);
}
.progress-bar i { display: block; height: 100%; background: var(--accent); }

/* ── 상세 ───────────────────────────────────────── */

/* 배경 이미지가 꽉 차는 작품 상세 */
.dt-hero {
  position: relative;
  min-height: 72vh;
  display: flex;
  align-items: flex-end;
  padding: 0 0 4px;
  overflow: hidden;
}
.dt-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
}
.dt-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(12,10,17,.55) 0%, rgba(12,10,17,.12) 26%, rgba(12,10,17,.86) 74%, var(--bg) 100%);
}
.dt-close {
  position: absolute;
  top: max(12px, var(--safe-t));
  right: 12px;
  z-index: 3;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(12,10,17,.62);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 17px;
  cursor: pointer;
}
.dt-info { position: relative; z-index: 2; width: 100%; padding: 0 16px 8px; }

.dt-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 11px; }
.dt-pill {
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.14);
  backdrop-filter: blur(6px);
  font-size: 11.5px;
  font-weight: 700;
}
.dt-pill.accent { background: rgba(139,111,199,.9); }
.dt-pill.new { background: var(--accent-strong); letter-spacing: .04em; }

.dt-title {
  margin: 0 0 10px;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.24;
  text-shadow: 0 2px 14px rgba(0,0,0,.6);
}
.dt-meta { font-size: 12.5px; color: #cdc6de; margin-bottom: 18px; }

.dt-actions { display: flex; align-items: center; gap: 20px; }
.dt-play {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  text-align: left;
}
.dt-play-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #fff;
  color: #16121f;
  display: grid;
  place-items: center;
  font-size: 20px;
  padding-left: 3px;
  flex: 0 0 auto;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.dt-play-text { font-size: 15px; font-weight: 700; }
.dt-play-text i {
  display: block;
  font-style: normal;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 2px;
}
.dt-play:active .dt-play-icon { transform: scale(.94); }

.dt-icon {
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px;
}
.dt-icon b { font-size: 21px; line-height: 1; font-weight: 400; }
.dt-icon span { font-size: 10.5px; color: var(--muted); }
.dt-icon.on b { color: var(--accent); }

.dt-desc { font-size: 13.5px; line-height: 1.7; color: #c6bfda; padding: 8px 16px 4px; margin: 0; }
.dt-desc.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ── 상세 모달 (PC) ─────────────────────────────── */
body.modal-open { overflow: hidden; }
.dt-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: rgba(6, 5, 10, .72);
  backdrop-filter: blur(7px);
  animation: dt-fade .16s ease;
}
@keyframes dt-fade { from { opacity: 0; } }
.dt-modal-card {
  position: relative;
  width: 100%;
  max-width: 880px;
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  animation: dt-pop .2s cubic-bezier(.2, .7, .3, 1);
  scrollbar-width: thin;
}
@keyframes dt-pop { from { opacity: 0; transform: translateY(16px) scale(.985); } }
.dt-modalbody { padding-bottom: 18px; }

.dt-mhead { display: flex; gap: 24px; padding: 30px 30px 8px; }
.dt-mposter {
  flex: 0 0 188px;
  width: 188px;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}
.dt-mposter img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dt-minfo { flex: 1; min-width: 0; padding-top: 6px; display: flex; flex-direction: column; }
.dt-minfo .dt-title { font-size: 24px; text-shadow: none; margin-bottom: 8px; }
.dt-minfo .dt-meta { margin-bottom: auto; }
.dt-minfo .dt-actions { margin-top: 22px; }

/* 모달 안에서는 히어로용 큰 값 대신 카드 폭에 맞춘 여백 */
.dt-modal-card .dt-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  border: 0;
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}
@media (hover: hover) { .dt-modal-card .dt-close:hover { background: rgba(255, 255, 255, .2); } }
.dt-modal-card .dt-desc { padding: 10px 30px 6px; }
.dt-modal-card .tabs { padding: 14px 30px 8px; }
.dt-modal-card .ep-bar { padding: 6px 30px 12px; }
.dt-modal-card .ep-rows,
.dt-modal-card .ep-grid { padding: 0 30px; }

/* 회차 목록 — 줄 형태 */
.ep-rows { display: flex; flex-direction: column; gap: 8px; padding: 0 14px; }
.eprow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  cursor: pointer;
}
.eprow:active { transform: scale(.995); }
.eprow.watching { border-color: var(--accent); }
.eprow.done { opacity: .62; }

.eprow-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 108px;
  aspect-ratio: 16/9;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elev);
}
.eprow-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.eprow-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
}
.eprow-thumb i { position: absolute; inset: auto 0 0 0; height: 3px; background: var(--accent); }

.eprow-body { flex: 1; min-width: 0; }
.eprow-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.eprow-title em { font-style: normal; font-size: 11px; color: var(--muted); }
.eprow-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.eprow-play { color: var(--muted); font-size: 13px; padding-right: 6px; }

.ep-new.inline { position: static; font-size: 9px; padding: 2px 5px; }
.ep-tools { display: flex; gap: 7px; }

.btn {
  border: 0;
  border-radius: 11px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
}
.btn { transition: background var(--ease), transform var(--ease), border-color var(--ease); }
.btn.primary { background: var(--accent-grad); border-color: transparent; color: #fff; flex: 1; box-shadow: 0 4px 14px rgba(125, 91, 198, .38); }
@media (hover: hover) { .btn:hover { border-color: var(--accent-strong); } .btn.primary:hover { filter: brightness(1.08); } }
.btn:active { transform: scale(.985); }

.tabs { display: flex; gap: 8px; padding: 16px 14px 10px; }
.tab {
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.tab.active { background: var(--accent-grad); border-color: transparent; color: #fff; font-weight: 700; }

.ep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  padding: 0 14px;
}
.ep {
  position: relative;
  padding: 13px 4px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
}
.ep.watching { border-color: var(--accent); }
.ep.done { color: var(--muted); }
.ep i {
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--accent);
}

/* 최신 화 표시 */
.ep-new {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 8.5px;
  font-weight: 800;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  background: var(--accent-strong);
  color: #fff;
}

/* 회차 목록 머리말 */
.ep-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 14px 10px;
}
.ep-count { font-size: 13px; color: var(--muted); font-weight: 600; }
.ep-sort {
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.ep-sort:active { transform: scale(.97); }

/* ── 검색 ───────────────────────────────────────── */

.search-bar { padding: 12px 14px; }
.search-bar input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.search-bar input:focus { border-color: var(--accent-strong); }

/* ── 설정 ───────────────────────────────────────── */

.settings { padding: 4px 14px; }
.set-group { margin-bottom: 26px; }
.set-group h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 0 0 10px 2px;
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
}
.set-row label { font-size: 14px; }
.set-row .hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.set-row select, .set-row input[type=number], .set-row input[type=color] {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13.5px;
  min-width: 92px;
}
.set-row input[type=color] { min-width: 52px; height: 36px; padding: 3px; }
.set-row input[type=range] { flex: 1; max-width: 160px; accent-color: var(--accent); }

.switch { position: relative; width: 46px; height: 27px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute;
  inset: 0;
  background: #3a3350;
  border-radius: 999px;
  transition: background .18s;
  cursor: pointer;
}
.switch span::before {
  content: "";
  position: absolute;
  width: 21px;
  height: 21px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .18s;
}
.switch input:checked + span { background: var(--accent-strong); }
.switch input:checked + span::before { transform: translateX(19px); }

/* ── 아이콘 크기 ────────────────────────────────── */
.dt-close svg { width: 20px; height: 20px; }
.dt-play-icon svg { width: 22px; height: 22px; margin-left: 2px; }
.dt-icon b svg { width: 24px; height: 24px; display: block; }
.dt-icon.on b { color: var(--accent); }
.eprow-play { display: grid; place-items: center; }
.eprow-play svg { width: 18px; height: 18px; display: block; }

/* 본 화 / 보던 화 표시 */
.eprow-name { color: var(--muted); font-weight: 500; }
.eprow-check { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10,8,16,.5); color: var(--accent); }
.eprow-check svg { width: 26px; height: 26px; }
.eprow.done .eprow-play { color: var(--accent); }
.ep-done { position: absolute; top: 3px; left: 4px; display: grid; place-items: center; color: var(--accent); }
.ep-done svg { width: 13px; height: 13px; }
.ep.done { color: var(--muted); }
.weprow.done { opacity: .58; }
.weprow.watching { border-color: var(--accent); }
.weprow-check { flex: 0 0 auto; color: var(--accent); display: grid; place-items: center; }
.weprow-check svg { width: 18px; height: 18px; }
.weprow-bar { flex: 0 0 44px; height: 3px; border-radius: 2px; background: rgba(255,255,255,.2); overflow: hidden; }
.weprow-bar i { display: block; height: 100%; background: var(--accent); }
.ep-sort.ico-btn { padding: 7px; width: 36px; display: grid; place-items: center; }
.ep-sort svg { width: 18px; height: 18px; display: block; }
.ic-inline { display: inline-flex; vertical-align: -3px; color: var(--accent); }
.ic-inline svg { width: 16px; height: 16px; }

/* ── 상태 표시 ──────────────────────────────────── */

.empty, .loading {
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}
.spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 14px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 18px);
  transform: translate(-50%, 14px);
  background: #241d36;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 17px;
  border-radius: 11px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 100;
  max-width: 84vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── 로그인 ─────────────────────────────────────── */

.login {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.login-box { width: 100%; max-width: 320px; text-align: center; }
.login-logo { color: var(--accent); width: 52px; height: 52px; margin: 0 auto 12px; display: grid; place-items: center; }
.login-logo svg { width: 50px; height: 50px; }
.login-box h1 { margin: 0 0 6px; font-size: 22px; }
.login-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.login-box input {
  width: 100%;
  padding: 13px 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 10px;
  outline: none;
}
.login-box input:focus { border-color: var(--accent-strong); }
.login-box button {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: 0;
  background: var(--accent-strong);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.login-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 10px; }

/* ══ 플레이어 ═══════════════════════════════════ */

.player-page { background: #000; min-height: 100vh; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.stage.fs {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  aspect-ratio: auto;
  z-index: 300;
}
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }

/* 자막 */
.subs {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8%;
  text-align: center;
  pointer-events: none;
  padding: 0 6%;
  z-index: 3;
  transition: bottom .18s;
}
.stage.controls-on .subs { bottom: calc(8% + 62px); }
.subs-line {
  display: inline-block;
  font-size: 22px;
  line-height: 1.4;
  font-weight: 600;
  color: #fff;
  text-shadow:
    -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000,
    -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000,
    0 2px 5px rgba(0,0,0,.8);
  padding: 1px 8px;
  border-radius: 5px;
  white-space: pre-wrap;
  word-break: keep-all;
}

/* 컨트롤 */
.controls {
  position: absolute;
  inset: 0;
  z-index: 5;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.62) 0%, transparent 22%, transparent 62%, rgba(0,0,0,.75) 100%);
}
.stage.controls-on .controls { opacity: 1; pointer-events: auto; }

.ctrl-top {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  padding-top: max(10px, var(--safe-t));
}
.ctrl-top .t {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
.ctrl-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 34px;
  /* 화면 전체를 덮지만 빈 영역은 클릭을 통과시켜야(뒤로가기·탭 제스처가 살아나도록) 한다.
     실제 버튼만 클릭을 받는다. */
  pointer-events: none;
}
.ctrl-center .pbtn { pointer-events: auto; }
.ctrl-bottom {
  position: absolute;
  inset: auto 0 0 0;
  padding: 0 12px 10px;
  padding-bottom: max(10px, var(--safe-b));
}

.pbtn {
  background: rgba(0,0,0,.34);
  border: 0;
  color: #fff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 17px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background var(--ease), transform var(--ease);
}
.pbtn svg { width: 22px; height: 22px; display: block; }
@media (hover: hover) { .pbtn:hover { background: rgba(0,0,0,.55); } }
.pbtn:active { transform: scale(.92); }
.pbtn.big { width: 64px; height: 64px; background: rgba(0,0,0,.42); }
.pbtn.big svg { width: 30px; height: 30px; }
.pbtn:disabled { opacity: .32; }
.pbtn.wide { width: auto; border-radius: 19px; padding: 0 13px; font-size: 12.5px; font-weight: 700; }
.pbtn.wide svg { width: 18px; height: 18px; }

.seek-row { display: flex; align-items: center; gap: 10px; }
.time { font-size: 11.5px; color: #ded8ee; font-variant-numeric: tabular-nums; flex: 0 0 auto; }

.seek {
  position: relative;
  flex: 1;
  height: 22px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}
.seek { flex: 1; padding: 10px 0; cursor: pointer; }
.seek-track { position: relative; width: 100%; height: 6px; border-radius: 4px; background: rgba(255,255,255,.28); transition: height var(--ease); }
.seek-buf { position: absolute; inset: 0 auto 0 0; background: rgba(255,255,255,.42); border-radius: 4px; }
.seek-fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(154,123,224,.6);
}
.seek-knob {
  position: absolute;
  top: 50%;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 6px rgba(0,0,0,.7);
}
@media (hover: hover) { .seek:hover .seek-track { height: 8px; } }
/* AniSkip 구간 표시 */
.seek-mark { position: absolute; top: 0; bottom: 0; background: rgba(255, 214, 102, .75); border-radius: 2px; }

.ctrl-row2 { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.ctrl-row2 .spacer { flex: 1; }

/* 스킵 버튼 */
.skip-btn {
  position: absolute;
  right: 14px;
  bottom: 74px;
  z-index: 6;
  background: rgba(20,16,30,.9);
  border: 1px solid rgba(255,255,255,.28);
  color: #fff;
  border-radius: 9px;
  padding: 10px 15px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  animation: rise .22s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* 더블탭 피드백 */
.tap-fx {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  pointer-events: none;
  opacity: 0;
  z-index: 4;
}
.tap-fx.l { left: 9%; }
.tap-fx.r { right: 9%; }
.tap-fx.go { animation: pop .5s ease; }
@keyframes pop {
  0% { opacity: 0; transform: translateY(-50%) scale(.7); }
  30% { opacity: 1; transform: translateY(-50%) scale(1); }
  100% { opacity: 0; transform: translateY(-50%) scale(1.12); }
}

/* 로딩 / 배너 */
.stage-spinner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 4;
  pointer-events: none;
}
.stage-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  text-align: center;
  z-index: 8;
  background: rgba(0,0,0,.8);
  font-size: 14px;
  line-height: 1.7;
}
.resume-toast {
  position: absolute;
  left: 12px;
  bottom: 74px;
  z-index: 6;
  background: rgba(20,16,30,.9);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 13px;
  font-size: 12.5px;
  animation: rise .22s ease;
}
.resume-toast button {
  background: none;
  border: 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  padding: 0 0 0 8px;
}

/* 재생 화면 하단 정보 */
.watch-info { padding: 14px; }
.watch-info h1 { font-size: 17px; margin: 0 0 4px; }
.watch-info .sub { color: var(--muted); font-size: 13px; }
.watch-nav { display: flex; gap: 8px; margin-top: 14px; }
.watch-nav .btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.watch-nav .btn svg { width: 18px; height: 18px; }

/* 시트(설정 팝업) */
/* 설정 시트 — stage 안에 절대배치(전체화면에서도 보이게) */
.sheet-back {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 400;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 82%;
  overflow-y: auto;
  background: var(--bg-elev);
  border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(20px + var(--safe-b));
  animation: sheetUp .22s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes sheetRight { from { transform: translateX(100%); } }
.sheet-grip { width: 38px; height: 4px; background: #4a4266; border-radius: 3px; margin: 8px auto 10px; }
.sheet-title { display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 800; padding: 0 2px 6px; }
.sheet-close { background: none; border: 0; color: var(--muted); width: 30px; height: 30px; display: grid; place-items: center; cursor: pointer; }
.sheet-close svg { width: 20px; height: 20px; }

/* 넓은 화면 / 전체화면: 오른쪽 패널로 */
@media (min-width: 760px) {
  .sheet-back { align-items: stretch; justify-content: flex-end; }
  .sheet {
    width: 360px;
    max-width: 360px;
    height: 100%;
    max-height: none;
    border-radius: 0;
    padding: 20px 20px calc(24px + var(--safe-b));
    animation: sheetRight .22s ease;
  }
  .sheet-grip { display: none; }
}
.sheet h3 { margin: 18px 0 9px 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sheet h3:first-of-type { margin-top: 4px; }
.opt-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 4px; }
.opt {
  padding: 8px 14px;
  border-radius: 9px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.opt.active { background: var(--accent-strong); border-color: var(--accent-strong); font-weight: 700; }

/* ── 음량 바 ────────────────────────────────────── */
.vol { display: flex; align-items: center; width: 0; overflow: hidden; transition: width var(--ease); }
.ctrl-row2:hover .vol, .vol:focus-within { width: 84px; }
@media (hover: none) { .vol { width: 70px; } }
.vol input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 3px;
  background: rgba(255,255,255,.35); outline: none; cursor: pointer;
}
.vol input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.6); }
.vol input[type=range]::-moz-range-thumb { width: 13px; height: 13px; border: 0; border-radius: 50%; background: #fff; }

.pbtn.only-pc { display: none; }
@media (min-width: 760px) { .pbtn.only-pc { display: grid; } }

/* ── 재생 화면 하단 회차 목록 ───────────────────── */
.watch-eps { padding: 6px 14px 20px; }
.watch-eps-head { font-size: 14px; font-weight: 800; padding: 6px 2px 10px; display: flex; gap: 7px; align-items: center; }
.watch-eps-head::before { content: ""; width: 4px; height: 15px; border-radius: 3px; background: var(--accent-grad); }
.watch-eps-head b { color: var(--accent); }
.watch-eps-list { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; }
.weprow {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg-card); border: 1px solid var(--line);
  color: var(--text); cursor: pointer; transition: background var(--ease), border-color var(--ease);
}
@media (hover: hover) { .weprow:hover { background: var(--bg-hover); } }
.weprow.active { border-color: var(--accent); background: linear-gradient(135deg, rgba(154,123,224,.16), rgba(125,91,198,.08)); }
.weprow-num { flex: 0 0 auto; min-width: 30px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); }
.weprow.active .weprow-num { color: var(--accent); }
.weprow-title { flex: 1; min-width: 0; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.weprow-play { flex: 0 0 auto; color: var(--muted); display: grid; place-items: center; }
.weprow-play svg { width: 17px; height: 17px; }
.weprow-now { flex: 0 0 auto; font-size: 11px; font-weight: 700; color: var(--accent); }

/* ── 극장 모드 (PC) ─────────────────────────────── */
@media (min-width: 760px) {
  .player-page.theater { background: #000; }
  .player-page.theater .stage {
    max-width: 100%;
    max-height: calc(100vh - 40px);
    width: 100%;
    border-radius: 0;
  }
  .player-page.theater .watch-info,
  .player-page.theater .watch-eps { max-width: 1100px; margin-left: auto; margin-right: auto; }
}

@media (min-width: 760px) {
  .view { padding-bottom: 30px; }
  .nav {
    top: calc(52px + var(--safe-t));
    bottom: auto;
    height: auto;
    width: 190px;
    flex-direction: column;
    border-top: 0;
    border-right: 1px solid var(--line);
    padding: 10px 8px;
    background: transparent;
  }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 13px; padding: 12px 14px; border-radius: 12px; font-size: 14.5px; font-weight: 600; transition: background var(--ease), color var(--ease); }
  .nav a .nav-ico, .nav a .nav-ico svg { width: 22px; height: 22px; }
  @media (hover: hover) { .nav a:hover { background: var(--bg-hover); color: var(--text); } }
  .nav a.active { background: linear-gradient(135deg, rgba(154,123,224,.18), rgba(125,91,198,.1)); color: var(--accent); }
  .nav a.active .nav-ico svg { transform: none; }
  .view { margin-left: 190px; }
  .topbar { padding-left: 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 20px 14px; }
  .stage { max-height: calc(100vh - 150px); aspect-ratio: 16/9; }
  .player-page .stage { margin: 0 auto; }
  .subs-line { font-size: 26px; }

  /* 재생화면은 좌측 사이드바 자리(빈 여백)를 없앤다 */
  .view.plain { margin-left: 0; }

  /* 기본 재생(극장·전체화면 아님): 영상 + 우측 회차 목록 */
  .player-page:not(.theater) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas: "stage eps" "info eps";
    gap: 0 18px;
    padding: 16px 18px;
    align-items: start;
  }
  .player-page:not(.theater) .stage { grid-area: stage; margin: 0; max-height: calc(100vh - 120px); }
  .player-page:not(.theater) .watch-info { grid-area: info; }
  .player-page:not(.theater) .watch-eps {
    grid-area: eps; padding: 0;
    max-height: calc(100vh - 32px); overflow-y: auto;
    position: sticky; top: 16px;
  }
  .player-page:not(.theater) .watch-eps-list { max-height: none; }

  /* PC 한눈에: 요일 7열 그리드 */
  .day-columns {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    padding: 0 14px;
    align-items: start;
  }
  .day-col {
    min-width: 0;
    border-radius: 12px;
    padding: 6px 6px 10px;
  }
  .day-col.active { background: var(--bg-card); }
  .day-col-head {
    padding: 4px 4px 12px;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text);
  }
  .day-col.active .day-col-head { color: var(--accent); }
  .day-col-head i {
    font-style: normal;
    font-size: 10px;
    font-weight: 700;
    margin-left: 5px;
    color: var(--accent);
  }
  .day-col-list { display: flex; flex-direction: column; gap: 16px; overflow: visible; }
  .day-col-list .card { flex: none; width: auto; }
  .day-col-list .card-title { font-size: 12px; margin-top: 6px; }
  .day-col-list .card-sub { font-size: 11px; }
  .day-col-empty {
    font-size: 11.5px;
    color: var(--muted);
    padding: 8px 4px;
  }
}
