/* K-Edufine Cinematic Tutorial Studio Design System */
@import url('https://fonts.googleapis.com/css2?family=Pretendard:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-main: #0b0f19;
  --bg-surface: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(31, 41, 55, 0.95);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(59, 130, 246, 0.5);
  
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.35);
  --accent: #f59e0b;
  --accent-glow: rgba(245, 158, 11, 0.45);
  --success: #10b981;
  --danger: #ef4444;
  
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  
  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition-fast: 150ms ease;
  --transition-normal: 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Header */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-decoration: none;
}
.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.brand-text h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge-version {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.brand-text p {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Search Box */
.search-wrapper {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition-fast);
}
.search-input:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.nav-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}
.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}
.stat-pill strong {
  color: #fff;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  font-family: inherit;
}
.btn-primary {
  background: #2563eb;
  color: #fff;
}
.btn-primary:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-color);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}
.btn-accent {
  background: #d97706;
  color: #fff;
}
.btn-accent:hover {
  background: #b45309;
}
.btn-icon {
  padding: 8px 10px;
}

/* ================================================= */
/* LIBRARY VIEW (BENTO / 12-BOOK DASHBOARD GRID)     */
/* ================================================= */
#library-view,
#catalog-view {
  max-width: 1720px;
  margin: 0 auto;
  padding: 16px 28px;
  box-sizing: border-box;
}

.catalog-hero {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(139, 92, 246, 0.14));
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 10px;
  padding: 12px 22px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  overflow: hidden;
}
.catalog-hero::after {
  content: '';
  position: absolute;
  right: -50px;
  top: -50px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.2), transparent 70%);
  pointer-events: none;
}
.hero-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.hero-left h2 {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  white-space: nowrap;
}
.hero-left .hero-desc {
  font-size: 12px;
  color: #cbd5e1;
  white-space: nowrap;
}
.hero-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}
.hero-tag {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

/* 12-Book Dashboard Grid */
.book-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 18px;
  margin-top: 10px;
}
@media (max-width: 1180px) {
  .book-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }
}
@media (max-width: 768px) {
  .book-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
}
.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: clamp(175px, 21vh, 225px);
  box-sizing: border-box;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}
.book-card:hover {
  transform: translateY(-4px);
  border-color: rgba(59, 130, 246, 0.65);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5);
}
.book-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--book-accent, #3b82f6);
}
.book-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.book-icon {
  font-size: 28px;
  line-height: 1;
  padding: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.book-meta {
  flex: 1;
  min-width: 0;
}
.book-meta h3 {
  font-size: 16.5px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.book-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}
.badge-cat {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #93c5fd;
  white-space: nowrap;
}
.badge-acc {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  white-space: nowrap;
}
.book-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 6px;
  height: 38px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.book-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  margin-top: auto;
}
.book-stats-row {
  display: flex;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.book-stats-row strong {
  color: #fff;
}

/* Global Search Result Cards */
.search-result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 18px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.search-result-card:hover {
  transform: translateY(-3px);
  border-color: rgba(59, 130, 246, 0.7);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}
.search-result-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--card-accent, #3b82f6);
}
.search-result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.search-result-manual {
  font-size: 12px;
  font-weight: 700;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.12);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(59, 130, 246, 0.25);
}
.search-result-cat {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-title {
  font-size: 15.5px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.35;
}
.search-result-title mark {
  background: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
  padding: 0 3px;
  border-radius: 3px;
}
.search-result-menu {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12px;
  color: var(--text-muted);
}

/* Section Header Shared Styles */
.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  margin-bottom: 4px;
}
.section-header-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.section-badge-info {
  font-size: 11.5px;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.2);
}
.section-count-label {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* Search Results Container & Header */
.search-results-section {
  display: none;
  margin-top: 8px;
}
.search-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}
.search-results-title {
  font-size: 15.5px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.search-results-count-badge {
  font-size: 12px;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.14);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.25);
}
.btn-clear-search {
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
}
.global-search-grid {
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

/* TOC View Styles */
#toc-view {
  display: none;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}
.breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.breadcrumb-bar a {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}
.toc-manual-title {
  color: #fff;
  font-weight: 600;
}
.toc-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
}
@media (max-width: 900px) {
  .toc-layout { grid-template-columns: 1fr; }
}
.chapter-menu {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  height: fit-content;
  position: sticky;
  top: 80px;
}
.chapter-menu h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-left: 6px;
}
.chapter-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  margin-bottom: 4px;
}
.chapter-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.chapter-link.active {
  background: var(--primary);
  color: #fff;
}
.chapter-count {
  font-size: 11px;
  opacity: 0.8;
}
.chapter-content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.chapter-content-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

/* Sidebar Specific Replacements */
.sidebar-header-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge-autosave {
  font-size: 10px;
  color: #10b981;
}

/* Category Filter Tabs */
.category-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}
.cat-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}
.cat-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.cat-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Clip Grid */
.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.clip-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.clip-card:hover {
  transform: translateY(-4px);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.card-thumb {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  background: #0f172a;
  overflow: hidden;
}
.card-thumb img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.clip-card:hover .card-thumb img {
  transform: scale(1.05);
}
.thumb-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(11, 15, 25, 0.8) 0%, transparent 60%);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 10px 14px;
}
.pill-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
}
.pill-category {
  background: rgba(37, 99, 235, 0.8);
  border-color: rgba(59, 130, 246, 0.5);
}

.card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.4;
  margin-bottom: 6px;
  height: 44px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-menu {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 12px;
  height: 34px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  gap: 8px;
}
.card-stats {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ================================================= */
/* CINEMATIC VIEWER VIEW (2-PANE)                    */
/* ================================================= */
#player-view {
  display: none;
  width: 100vw;
  height: calc(100vh - 63px);
  overflow: hidden;
  background: #000;
}
#player-view.active {
  display: flex;
}

/* Left Pane: Cinematic Viewport */
.cinema-pane {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
  overflow: hidden;
}

.cinema-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.85) 0%, transparent 100%);
  pointer-events: none;
}
.cinema-header > * {
  pointer-events: auto;
}
.cinema-title-group {
  max-width: 70%;
}
.cinema-clip-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}
.cinema-clip-meta {
  font-size: 12px;
  color: #d1d5db;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Cinema Viewport Stage (True Centering Fixed) */
.cinema-stage-wrapper {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: #090d16;
}

#stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  transform-origin: 50% 50%;
  transition: transform 0.65s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
}

#stage img {
  display: block;
  max-width: calc(100vw * 0.62);
  max-height: calc(100vh - 160px);
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  user-select: none;
  -webkit-user-drag: none;
}

/* Amber Radar Target Ring */
.target-ring {
  position: absolute;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  margin-top: -26px;
  border: 3px solid #f59e0b;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.22);
  box-shadow: 0 0 22px rgba(245, 158, 11, 0.8), inset 0 0 14px rgba(245, 158, 11, 0.4);
  animation: radar-ping 1.3s cubic-bezier(0, 0, 0.2, 1) infinite;
  z-index: 10;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.target-ring::after {
  content: '';
  position: absolute;
  left: -12px;
  top: -12px;
  right: -12px;
  bottom: -12px;
  border-radius: 50%;
}
.target-ring .badge-num {
  position: absolute;
  top: -12px;
  right: -12px;
  background: #ef4444;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  border: 2px solid #fff;
}
@keyframes radar-ping {
  0% { transform: scale(0.92); opacity: 0.9; }
  50% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 28px rgba(245, 158, 11, 1); }
  100% { transform: scale(0.92); opacity: 0.9; }
}

/* Virtual Cursor */
#virtual-cursor {
  position: absolute;
  width: 32px;
  height: 32px;
  z-index: 15;
  pointer-events: none;
  transition: left 0.75s cubic-bezier(0.22, 1, 0.36, 1), top 0.75s cubic-bezier(0.22, 1, 0.36, 1), transform 0.2s ease;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.6));
}
#virtual-cursor.click-animation {
  transform: scale(0.78);
}

/* Subtitle HUD Bar */
.subtitle-hud {
  position: absolute;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  max-width: 85%;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  transition: opacity 0.2s ease;
}
.subtitle-speaker-icon {
  font-size: 20px;
  color: #3b82f6;
  flex-shrink: 0;
}
.subtitle-text {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  line-height: 1.45;
}

/* Bottom Player Controller */
.cinema-controls {
  position: relative;
  z-index: 30;
  background: rgba(15, 23, 42, 0.96);
  border-top: 1px solid var(--border-color);
  padding: 10px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-bar-wrapper {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}
.timeline-progress {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.controls-left, .controls-center, .controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.step-indicator {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  min-width: 90px;
}
.mode-toggle-group {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 2px;
}
.mode-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}
.mode-btn.active {
  background: #2563eb;
  color: #fff;
}

.speed-select, .voice-select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: #fff;
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
  font-family: inherit;
}
.voice-select {
  max-width: 150px;
}

/* Right Pane: Step Navigator & Notes */
.sidebar-pane {
  width: 380px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.step-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-card {
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition-fast);
}
.step-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}
.step-card.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: #3b82f6;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.2);
}
.step-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.step-num-pill {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #374151;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-card.active .step-num-pill {
  background: #2563eb;
}
.step-target-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}
.step-action-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Bottom Sidebar Panels: Memo & Next Clip Chain */
.sidebar-bottom-panel {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(11, 15, 25, 0.6);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.memo-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}
.memo-textarea {
  width: 100%;
  height: 56px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  resize: none;
  outline: none;
}
.memo-textarea:focus {
  border-color: var(--primary);
}

.workflow-chain-card {
  display: none;
  padding: 10px 12px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.25));
  border: 1px solid rgba(16, 185, 129, 0.4);
  cursor: pointer;
  transition: var(--transition-fast);
}
.workflow-chain-card:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(5, 150, 105, 0.35));
}
.workflow-chain-card.active {
  display: block;
}
.chain-label {
  font-size: 11px;
  font-weight: 700;
  color: #34d399;
  text-transform: uppercase;
}
.chain-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

/* ================================================= */
/* 400PX SIDEBAR DOCKING MODE (DESKTOP)              */
/* ================================================= */
body.sidebar-mode {
  max-width: 420px !important;
  margin: 0 0 0 auto !important;
  border-left: 2px solid var(--primary);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.8);
}
body.sidebar-mode .sidebar-pane {
  display: none; /* Hide right panel to focus on cinema stage */
}
body.sidebar-mode #stage img {
  max-width: 100% !important;
  max-height: calc(100vh - 200px) !important;
}
body.sidebar-mode .top-nav {
  padding: 8px 12px;
}
body.sidebar-mode .search-wrapper,
body.sidebar-mode .nav-stats {
  display: none;
}

/* Mobile Player Elements Defaults (Desktop) */
.btn-mobile-steps-toggle,
#btn-mobile-mute {
  display: none;
}
.btn-close-sidebar {
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
}
.btn-close-sidebar:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
}

/* Mobile Sidebar Backdrop Overlay */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 295;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ================================================= */
/* COMPREHENSIVE RESPONSIVE MOBILE STYLES            */
/* ================================================= */

/* Tablet & Mobile (<= 900px) */
@media (max-width: 900px) {
  #player-view {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
  }

  /* Transform Sidebar into Slide-over Drawer */
  .sidebar-pane {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 88vw;
    max-width: 380px;
    z-index: 300;
    box-shadow: -12px 0 45px rgba(0, 0, 0, 0.95);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    background: #111827;
    display: flex;
    flex-direction: column;
  }
  .sidebar-pane.mobile-open {
    transform: translateX(0);
  }
  .btn-close-sidebar {
    display: inline-flex;
  }
  .btn-mobile-steps-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 11px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.5);
    color: #93c5fd;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
  }
  #btn-mobile-mute {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  /* Full Width Stage on Mobile */
  .cinema-pane {
    width: 100vw;
    height: 100%;
    position: relative;
  }
  #stage img {
    max-width: 98vw;
    max-height: calc(100dvh - 190px);
    width: auto;
    height: auto;
    object-fit: contain;
  }
}

/* Mobile Devices (<= 768px) */
@media (max-width: 768px) {
  /* Top Nav */
  .top-nav {
    padding: 10px 14px;
    gap: 10px;
  }
  .brand-icon {
    width: 32px;
    height: 32px;
    font-size: 17px;
  }
  .brand-text h1 {
    font-size: 15px;
    gap: 6px;
  }
  .brand-text p {
    display: none; /* Hide long subtitle to save header height */
  }
  #btn-toggle-sidebar-mode {
    display: none; /* Hide 400px sidebar mode on mobile screens */
  }
  .btn-builder-link {
    padding: 6px 9px;
    font-size: 12px;
  }
  .btn-builder-text {
    display: none; /* Icon-only on mobile */
  }
  .search-wrapper {
    max-width: 100%;
  }
  .search-input {
    font-size: 13px;
    padding: 8px 12px 8px 34px;
  }

  /* Tier 1 Library: Mobile Full Width & Fluid Card Grid */
  #library-view {
    padding: 12px 14px !important;
  }
  .book-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .book-card {
    height: auto !important;
    min-height: 152px !important;
    padding: 14px 16px !important;
  }
  .book-card-title {
    font-size: 15.5px !important;
    line-height: 1.35 !important;
    white-space: normal !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }
  .book-card-desc {
    font-size: 12.5px !important;
    -webkit-line-clamp: 2 !important;
    margin-bottom: 10px !important;
  }
  .search-result-card {
    padding: 12px 14px !important;
  }
  .search-result-title {
    font-size: 14.5px !important;
  }

  /* TOC Layout: Horizontal Scrollable Chapter Pills */
  .toc-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .chapter-menu {
    position: sticky;
    top: 58px;
    z-index: 50;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
  }
  .chapter-menu h4 {
    display: none;
  }
  #chapter-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #chapter-list::-webkit-scrollbar {
    display: none;
  }
  .chapter-link {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 6px 12px;
    font-size: 12px;
    margin-bottom: 0;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.06);
  }
  .chapter-link.active {
    background: var(--primary);
    color: #fff;
  }

  /* Cinematic Player Header */
  .cinema-header {
    padding: 8px 12px;
    gap: 8px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.96) 0%, rgba(0, 0, 0, 0.78) 75%, transparent 100%);
  }
  .btn-back-compact {
    padding: 6px 10px;
    font-size: 12.5px;
    flex-shrink: 0;
    border-radius: 8px;
  }
  .cinema-title-group {
    flex: 1;
    min-width: 0;
    max-width: none;
  }
  .cinema-clip-title {
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
  }
  .cinema-clip-meta {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Stage Viewport Padding to avoid overlay collision */
  .cinema-stage-wrapper {
    flex: 1;
    width: 100%;
    height: 100%;
    padding-top: 48px;
    padding-bottom: 100px;
    box-sizing: border-box;
  }

  /* Mobile Practice Ring Touch Sensitivity */
  .target-ring {
    width: 58px;
    height: 58px;
    margin-left: -29px;
    margin-top: -29px;
    touch-action: manipulation;
  }
  .target-ring::after {
    left: -16px;
    top: -16px;
    right: -16px;
    bottom: -16px;
  }

  /* Subtitle HUD: Floating Above Controls */
  .subtitle-hud {
    bottom: 108px;
    max-width: 95%;
    width: calc(100% - 24px);
    padding: 8px 14px;
    border-radius: 12px;
    gap: 9px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: rgba(15, 23, 42, 0.94);
    border: 1px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  }
  .subtitle-speaker-icon {
    font-size: 15px;
    flex-shrink: 0;
  }
  .subtitle-text {
    font-size: 12.5px;
    line-height: 1.4;
    font-weight: 500;
  }

  /* Player Controls (Thumb-friendly 2-Row Layout on Mobile) */
  .cinema-controls {
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)) 12px;
    gap: 6px;
    background: rgba(11, 15, 25, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }
  .controls-row {
    flex-direction: column;
    gap: 6px;
  }
  .controls-left {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .controls-center {
    width: 100%;
    margin-left: 0;
  }
  .mode-toggle-group {
    width: 100%;
    display: flex;
  }
  .mode-btn {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    font-size: 12px;
    font-weight: 600;
  }
  .controls-right {
    display: none; /* Merged into controls-left or header */
  }
  .controls-left .btn {
    min-height: 38px;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 8px;
  }
  #btn-play-pause {
    flex: 1;
    font-weight: 700;
  }
  .step-indicator {
    font-size: 12px;
    font-weight: 600;
    min-width: 68px;
    text-align: right;
    color: #93c5fd;
  }

  /* Catalog & Library Hero adjustments */
  .catalog-hero {
    padding: 14px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .hero-left h2 {
    font-size: 16px;
  }
  .hero-left .hero-desc {
    font-size: 12px;
    white-space: normal;
  }
  .hero-badges {
    gap: 6px;
    flex-wrap: wrap;
  }
  .hero-tag {
    font-size: 11px;
    padding: 3px 8px;
  }

  /* Clip Cards on Mobile */
  .clip-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .card-body {
    padding: 12px 14px;
  }
  .card-title {
    font-size: 14.5px;
    height: auto;
    max-height: 42px;
  }
  .card-desc {
    font-size: 12px;
    height: auto;
    max-height: 34px;
    margin-bottom: 8px;
  }
}

/* Very Small Mobile Screens (<= 480px) */
@media (max-width: 480px) {
  .top-nav {
    flex-wrap: wrap;
    padding: 8px 12px;
  }
  .brand {
    width: 100%;
    justify-content: flex-start;
  }
  .search-wrapper {
    width: 100%;
    margin-top: 4px;
  }
  .controls-row {
    gap: 5px;
  }
  .btn-back-text {
    display: none; /* Show only arrow icon on extra small screens */
  }
  .mode-btn {
    padding: 7px 6px;
    font-size: 11px;
  }
  .subtitle-hud {
    bottom: 104px;
    padding: 7px 11px;
  }
  .subtitle-text {
    font-size: 12px;
  }
}

/* ================================================= */
/* ADMIN AUTH MODAL (챗봇 관리자 로그인 연계)         */
/* ================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modal-fade-in 0.2s ease;
}
.modal-dialog {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(59, 130, 246, 0.2);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  animation: modal-scale-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-dialog.shake {
  animation: modal-shake 0.4s ease;
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
}
.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-icon {
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-title-group h3 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.modal-title-group p {
  font-size: 12px;
  color: var(--text-secondary);
}
.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition-fast);
}
.btn-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.modal-body {
  padding: 22px;
}
.modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 18px;
}
.modal-desc strong {
  color: #60a5fa;
}
.modal-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  transition: var(--transition-fast);
}
.modal-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(0, 0, 0, 0.6);
}
.auth-error-msg {
  font-size: 12px;
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 12px;
}
.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-scale-up {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes modal-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
