/**
 * 고스트스테이션 모바일 플레이어 PWA 스타일시트
 * 다크 테마 기본, 모바일 세로 최적화, 대형 터치 영역, 순수 CSS (외부 폰트/CDN 배제)
 */

:root {
  --bg-primary: #121216;
  --bg-secondary: #1a1a24;
  --bg-card: #222230;
  --bg-active: #2d2d40;
  --accent-purple: #a855f7;
  --accent-red: #ff3b69;
  --accent-glow: rgba(255, 59, 105, 0.35);
  --text-main: #f3f4f6;
  --text-sub: #9ca3af;
  --text-muted: #6b7280;
  --border-color: #2e2e3e;
  --highlight-bg: rgba(168, 85, 247, 0.15);
  --highlight-border: #a855f7;
  --touch-target: 44px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

/* 앱 전체 컨테이너 */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-primary);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
}

/* 상단 헤더 */
.app-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  border-radius: 8px;
}

.header-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-sub);
  background-color: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 12px;
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10b981;
}

/* 메인 영역 및 탭 */
.app-main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.tab-content {
  display: none;
  height: 100%;
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-content.active {
  display: block;
}

/* 1. 회차 목록 화면 */
#tab-episodes {
  padding: 12px 16px 80px 16px;
}

/* 이어듣기 배너 카드 */
.resume-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #2a1b38 0%, #1e1b29 100%);
  border: 1px solid #7c3aed;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
  cursor: pointer;
}

.resume-badge {
  background-color: var(--accent-purple);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 6px;
  flex-shrink: 0;
}

.resume-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.resume-ep {
  font-size: 0.75rem;
  font-weight: 700;
  color: #c084fc;
}

.resume-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resume-pos {
  font-size: 0.75rem;
  color: var(--text-sub);
}

.btn-resume-play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--accent-purple);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-resume-play .svg-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* 검색창 */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  stroke: var(--text-muted);
  stroke-width: 2;
  fill: none;
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 46px;
  padding: 0 40px 0 42px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 23px;
  font-size: 0.95rem;
  color: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}

.btn-clear {
  position: absolute;
  right: 12px;
  width: 24px;
  height: 24px;
  border: none;
  background: var(--border-color);
  color: #fff;
  border-radius: 50%;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* 리스트 메타 정보 */
.list-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding: 0 4px;
}

.filter-check-label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}

/* 회차 목록 아이템 */
.episode-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.episode-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.1s, background-color 0.15s, border-color 0.15s;
  min-height: 56px;
}

.episode-item:active {
  transform: scale(0.985);
  background-color: var(--bg-active);
}

.episode-item.playing {
  border-color: var(--accent-purple);
  background-color: rgba(168, 85, 247, 0.1);
}

.ep-left {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.ep-num-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-purple);
  background-color: rgba(168, 85, 247, 0.15);
  padding: 4px 7px;
  border-radius: 8px;
  flex-shrink: 0;
}

.ep-texts {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ep-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ep-duration {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.ep-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ep-completed-badge {
  font-size: 0.7rem;
  color: #10b981;
  background-color: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 6px;
  border-radius: 6px;
}

.ep-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--border-color);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  pointer-events: none;
}

.episode-item.playing .ep-play-btn {
  background-color: var(--accent-purple);
}

.ep-play-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* 2. 재생 화면 탭 */
#tab-player {
  padding-bottom: 70px;
}

.player-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px;
}

.player-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 8px;
  margin-bottom: 12px;
}

.player-cover {
  width: 180px;
  height: 180px;
  position: relative;
  margin-bottom: 16px;
}

.player-art {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
  object-fit: cover;
  position: relative;
  z-index: 2;
}

.playing-glow {
  position: absolute;
  top: 5%;
  left: 5%;
  width: 90%;
  height: 90%;
  background: radial-gradient(circle, var(--accent-red) 0%, transparent 70%);
  filter: blur(20px);
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 1;
}

.playing-glow.active {
  opacity: 0.6;
}

.player-ep-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-purple);
  background-color: rgba(168, 85, 247, 0.15);
  padding: 3px 8px;
  border-radius: 10px;
  margin-bottom: 6px;
  display: inline-block;
}

.player-ep-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.4;
  margin-bottom: 4px;
  max-width: 90%;
  word-break: keep-all;
}

.player-sub {
  font-size: 0.85rem;
  color: var(--text-sub);
}

/* 노래 건너뛰기 배너 */
.skip-music-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, #371b26 0%, #20142b 100%);
  border: 1px solid var(--accent-red);
  border-radius: 12px;
  padding: 8px 14px;
  margin-bottom: 12px;
  animation: pulse-border 1.5s infinite;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 105, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(255, 59, 105, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 105, 0); }
}

.skip-music-text {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ff9bbb;
}

.btn-skip-music {
  background-color: var(--accent-red);
  color: #fff;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 18px;
  cursor: pointer;
}

/* 프로그레스 바 */
.progress-section {
  margin-bottom: 16px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #333344;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.1s;
}

.progress-bar:active::-webkit-slider-thumb {
  transform: scale(1.3);
  background: var(--accent-purple);
}

.time-display {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

/* 보조 컨트롤 */
.aux-controls {
  display: flex;
  justify-content: space-around;
  margin-bottom: 14px;
}

.aux-btn {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-sub);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  min-height: var(--touch-target);
}

.aux-btn:active {
  background-color: var(--bg-active);
  color: #fff;
}

.aux-icon {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.aux-value {
  color: #fff;
}

/* 메인 컨트롤러 */
.main-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  margin-bottom: 16px;
}

.btn-control {
  background: none;
  border: none;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
}

.btn-control:active {
  transform: scale(0.9);
  color: var(--accent-purple);
}

.btn-control svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.5;
}

.btn-seek {
  position: relative;
}

.btn-seek svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  width: 32px;
  height: 32px;
}

.seek-num {
  position: absolute;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-main);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%);
}

.btn-play-large {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent-purple) 0%, #9333ea 100%);
  color: #fff;
  border-radius: 50%;
  box-shadow: 0 6px 16px rgba(168, 85, 247, 0.4);
}

.btn-play-large svg {
  width: 30px;
  height: 30px;
  fill: #fff;
  stroke: none;
}

/* 대본 (가사 모드) 영역 */
.transcript-section {
  flex: 1;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 220px;
}

.transcript-header {
  padding: 10px 14px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.transcript-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.transcript-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.transcript-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.transcript-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
}

.transcript-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  color: var(--text-sub);
  font-size: 0.92rem;
  line-height: 1.5;
}

.transcript-line:hover, .transcript-line:active {
  background-color: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.transcript-line.active {
  background-color: var(--highlight-bg);
  border-left: 3px solid var(--highlight-border);
  color: #fff;
  font-weight: 600;
}

.line-text {
  flex: 1;
}

.btn-bookmark {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  flex-shrink: 0;
}

.btn-bookmark svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  transition: transform 0.15s, color 0.15s;
}

.btn-bookmark.bookmarked {
  color: var(--accent-red);
}

.btn-bookmark.bookmarked svg {
  fill: var(--accent-red);
  stroke: var(--accent-red);
  transform: scale(1.1);
}

/* 3. 명대사(북마크) 탭 */
#tab-bookmarks {
  padding: 16px 16px 80px 16px;
}

.bookmarks-header {
  margin-bottom: 16px;
}

.bookmarks-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.bookmarks-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.bookmarks-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bookmark-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.bookmark-card:active {
  background-color: var(--bg-active);
  border-color: var(--accent-purple);
}

.bm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.bm-ep-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: #c084fc;
}

.bm-time-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.bm-quote {
  font-size: 0.92rem;
  color: #fff;
  line-height: 1.45;
  margin-bottom: 8px;
}

.bm-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bm-ep-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 75%;
}

.btn-delete-bm {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px 8px;
}

.empty-bookmarks {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-icon {
  width: 44px;
  height: 44px;
  stroke: var(--border-color);
  stroke-width: 1.5;
  fill: none;
  margin: 0 auto 12px auto;
  display: block;
}

/* 하단 미니 플레이어 */
.mini-player {
  position: absolute;
  bottom: 60px;
  left: 0;
  right: 0;
  height: 56px;
  background-color: rgba(26, 26, 36, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
}

.mini-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background-color: var(--accent-purple);
  transition: width 0.2s linear;
}

.mini-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  overflow: hidden;
  cursor: pointer;
}

.mini-art {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  flex-shrink: 0;
}

.mini-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mini-ep {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-purple);
}

.mini-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-mini-control {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: none;
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-mini-control svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* 하단 탭 내비게이션 */
.app-nav {
  height: 60px;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-shrink: 0;
  padding-bottom: var(--safe-bottom);
  z-index: 30;
}

.nav-btn {
  flex: 1;
  height: 100%;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  cursor: pointer;
  min-height: var(--touch-target);
  transition: color 0.15s;
}

.nav-btn.active {
  color: var(--accent-purple);
}

.nav-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.nav-btn.active .nav-icon polygon {
  fill: currentColor;
}

.nav-label {
  font-size: 0.72rem;
  font-weight: 600;
}

/* 유틸리티 */
.hidden {
  display: none !important;
}

/* 대본 검색 결과 */
#transcript-hits { display: contents; }
.hits-header {
  list-style: none;
  padding: 16px 16px 6px;
  font-size: 0.8rem;
  color: #9ca3af;
}
.search-hit .ep-title { white-space: normal; line-height: 1.4; }
.search-hit .ep-title b { color: #a78bfa; font-weight: 700; }
