/* ==========================================
   DNIC E-Book CMS Platform Design System
   ========================================== */

/* 1. Global Reset & Typography */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  -webkit-font-smoothing: antialiased;
}

:root {
  --primary: #5856d6;
  --primary-hover: #4745b4;
  --primary-glow: rgba(88, 86, 214, 0.4);
  --success: #34c759;
  --danger: #ff3b30;
  
  /* Light Theme Variables */
  --bg-light: #f5f7fa;
  --text-light: #2c2c2e;
  --card-light: rgba(255, 255, 255, 0.8);
  --border-light: rgba(0, 0, 0, 0.08);

  /* Dark Theme Variables */
  --bg-dark: #090a0f;
  --text-dark: #f2f2f7;
  --card-dark: rgba(20, 22, 35, 0.7);
  --border-dark: rgba(255, 255, 255, 0.08);
  
  /* Sepia Theme Variables */
  --bg-sepia: #f4ecd8;
  --text-sepia: #5f4b32;
  --card-sepia: rgba(253, 251, 243, 0.8);
  --border-sepia: rgba(95, 75, 50, 0.15);
}

body {
  overflow-x: hidden;
}

/* ==========================================
   A. CMS Dashboard Styles (Dark Glassmorphic)
   ========================================== */
.cms-body {
  background-color: var(--bg-dark);
  color: var(--text-dark);
  min-height: 100vh;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* Glass Background Orbs */
.glass-bg-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.glass-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.4;
  animation: orbFloat 20s infinite alternate ease-in-out;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: var(--primary);
  top: -100px;
  right: -100px;
  animation-duration: 25s;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: #30d158;
  bottom: -150px;
  left: -150px;
  animation-duration: 30s;
}

@keyframes orbFloat {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(50px, 30px) scale(1.15); }
}

/* Glassmorphism Card Style */
.cms-card {
  background: var(--card-dark);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-dark);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 40px 30px;
  animation: cardFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand-header {
  text-align: center;
  margin-bottom: 35px;
}

.logo-symbol {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--primary), #8e2de2);
  border-radius: 16px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 15px;
  box-shadow: 0 8px 16px var(--primary-glow);
}

.brand-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  background: linear-gradient(to right, #fff, #b3b3b3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-header p {
  color: #8e8e93;
  font-size: 14px;
}

/* Input Fields styling */
.input-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
}

.input-group label {
  font-size: 13px;
  font-weight: 600;
  color: #a1a1aa;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-group label i {
  width: 14px;
  height: 14px;
}

.input-group input[type="text"],
.input-group input[type="password"],
.input-group input[type="number"],
.input-group textarea {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 12px 16px;
  color: #fff;
  font-size: 14px;
  transition: all 0.2s ease;
  width: 100%;
}

.input-group input:focus,
.input-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Buttons styling */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(255, 59, 48, 0.15);
  color: #ff453a;
  border: 1px solid rgba(255, 59, 48, 0.2);
}

.btn-danger:hover {
  background: rgba(255, 59, 48, 0.25);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  background: transparent;
  border: none;
  color: #a1a1aa;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* ==========================================
   B. CMS Dashboard Layout (Active Dashboard)
   ========================================== */
.cms-body.dashboard-active {
  display: block;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.dashboard-layout {
  display: flex;
  width: 100vw;
  min-height: 100vh;
  position: relative;
}

/* Left Sidebar styling */
.dashboard-sidebar {
  width: 280px;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: rgba(20, 22, 35, 0.4);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-right: 1px solid var(--border-dark);
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 100;
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
  animation: slideRight 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.sidebar-brand .logo-symbol {
  width: 42px;
  height: 42px;
  font-size: 20px;
  border-radius: 10px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.brand-text h2 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.brand-text .sub-text {
  font-size: 10px;
  color: #8e8e93;
}

/* Sidebar Nav styling */
.sidebar-nav {
  flex-grow: 1;
}

.sidebar-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #8e8e93;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  transition: all 0.25s ease;
}

.sidebar-nav li a i {
  width: 18px;
  height: 18px;
}

.sidebar-nav li.active a,
.sidebar-nav li a:hover {
  color: #fff;
  background: rgba(88, 86, 214, 0.15);
  box-shadow: inset 0 0 0 1px rgba(88, 86, 214, 0.2);
}

.sidebar-nav li.active a {
  background: var(--primary);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.disabled-nav {
  opacity: 0.6;
}

/* Sidebar Profile badge */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 20px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar-circle {
  width: 38px;
  height: 38px;
  background: rgba(88, 86, 214, 0.15);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #9d9bf6;
  border: 1px solid rgba(88, 86, 214, 0.2);
}

.user-avatar-circle i {
  width: 16px;
  height: 16px;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.user-role {
  font-size: 11px;
  color: #8e8e93;
}

/* Right Main Panel styling */
.dashboard-main {
  margin-left: 280px;
  width: calc(100% - 280px);
  min-height: 100vh;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  animation: cardFadeIn 0.5s ease-out;
}

/* Sticky Page Header */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: transparent;
  z-index: 50;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-dark);
}

.header-title h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  background: linear-gradient(to right, #fff, #b3b3b3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-title p {
  color: #8e8e93;
  font-size: 13px;
}

/* Stats Summary Dashboard Cards styling */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 10px;
}

.stats-card {
  background: rgba(20, 22, 35, 0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-dark);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transition: all 0.25s ease;
}

.stats-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.stats-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stats-icon-wrapper i {
  width: 20px;
  height: 20px;
}

.purple-glow {
  background: rgba(88, 86, 214, 0.15);
  color: #9d9bf6;
  border: 1px solid rgba(88, 86, 214, 0.25);
  box-shadow: 0 4px 12px rgba(88, 86, 214, 0.1);
}

.green-glow {
  background: rgba(52, 199, 89, 0.15);
  color: #30d158;
  border: 1px solid rgba(52, 199, 89, 0.25);
  box-shadow: 0 4px 12px rgba(52, 199, 89, 0.1);
}

.blue-glow {
  background: rgba(0, 122, 255, 0.15);
  color: #0a84ff;
  border: 1px solid rgba(0, 122, 255, 0.25);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.1);
}

.stats-data {
  display: flex;
  flex-direction: column;
}

.stats-val {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
}

.stats-label {
  font-size: 12px;
  color: #8e8e93;
  margin-top: 4px;
}

/* Document section listing headers */
.projects-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title-bar h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title-bar h3 i {
  width: 18px;
  height: 18px;
}

/* Project Cards Grid */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 25px;
  margin-bottom: 50px;
}

.project-card {
  background: var(--card-dark);
  border: 1px solid var(--border-dark);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transition: all 0.3s ease;
}

.project-card:hover {
  transform: translateY(-5px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.card-cover {
  height: 180px;
  background: #1c1c1e;
  position: relative;
  overflow: hidden;
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.project-card:hover .card-cover img {
  transform: scale(1.05);
}

.card-cover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(9, 10, 15, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card-cover:hover .card-cover-overlay {
  opacity: 1;
}

.card-details {
  padding: 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-desc {
  font-size: 13px;
  color: #8e8e93;
  line-height: 1.4;
  height: 38px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-status-badges {
  display: flex;
  gap: 8px;
}

.badge {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: #8e8e93;
}

.badge.active {
  background: rgba(88, 86, 214, 0.15);
  color: #9d9bf6;
  border: 1px solid rgba(88, 86, 214, 0.2);
}

.card-stats {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 12px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #a1a1aa;
}

.card-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-actions {
  padding: 15px 20px;
  background: rgba(0, 0, 0, 0.2);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

/* Spinner and Grid Messages */
.grid-loading, .grid-empty, .grid-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  background: var(--card-dark);
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  color: #8e8e93;
}

.spinner {
  width: 35px;
  height: 35px;
  border: 3px solid rgba(88, 86, 214, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================
   C. CMS Project Management Modal
   ========================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: var(--card-dark);
  border: 1px solid var(--border-dark);
  border-radius: 24px;
  width: 100%;
  max-width: 950px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
  animation: cardFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  padding: 20px 30px;
  border-bottom: 1px solid var(--border-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-body {
  padding: 30px;
  overflow-y: auto;
  flex-grow: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.required {
  color: var(--danger);
}

/* Checkbox Toggle Switch style */
.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 15px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(20px);
}

.toggle-label {
  display: flex;
  flex-direction: column;
}

.toggle-label strong {
  font-size: 14px;
}

.toggle-label .sub-text {
  font-size: 11px;
  color: #8e8e93;
}

/* Drag & Drop File Upload style */
.upload-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  padding-top: 20px;
}

.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 25px 15px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(88, 86, 214, 0.05);
}

.dz-icon {
  width: 32px;
  height: 32px;
  color: #8e8e93;
}

.dz-text {
  font-size: 13px;
  font-weight: 500;
}

.dz-subtext {
  font-size: 11px;
  color: #636366;
}

/* Realtime Upload Progress monitoring */
.upload-progress {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-bar-container {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8e2de2);
  border-radius: 3px;
  transition: width 0.1s ease;
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #a1a1aa;
}

.prog-pct {
  font-weight: bold;
  color: #fff;
}

.file-uploaded-info {
  background: rgba(52, 199, 89, 0.1);
  border: 1px solid rgba(52, 199, 89, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.success-icon {
  color: var(--success);
  width: 18px;
  height: 18px;
}

.file-name {
  flex-grow: 1;
  margin-left: 10px;
  font-weight: 500;
}

.btn-clear-file {
  background: transparent;
  border: none;
  color: #ff453a;
  cursor: pointer;
  padding: 4px;
}

/* TOC Tabs Mapping interface style */
.toc-mapping-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toc-instructions {
  font-size: 12px;
  color: #8e8e93;
  line-height: 1.4;
}

.toc-list-wrapper {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-dark);
  border-radius: 12px;
  height: 310px;
  overflow-y: auto;
  position: relative;
}

.toc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.toc-table th {
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
  padding: 10px;
  color: #8e8e93;
  border-bottom: 1px solid var(--border-dark);
  position: sticky;
  top: 0;
  z-index: 10;
}

.toc-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.toc-input-label, .toc-input-page {
  padding: 6px 10px !important;
  font-size: 12px !important;
}

.color-picker-wrapper {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.color-picker-wrapper input[type="color"] {
  border: none;
  width: 45px;
  height: 45px;
  transform: translate(-5px, -5px);
  cursor: pointer;
}

.toc-empty-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #636366;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.toc-empty-msg i {
  width: 24px;
  height: 24px;
}

.modal-footer {
  padding: 20px 30px;
  border-top: 1px solid var(--border-dark);
  display: flex;
  justify-content: flex-end;
  gap: 15px;
}

.hidden {
  display: none !important;
}

body.modal-open {
  overflow: hidden;
}

/* ==========================================
   D. E-Book 3D Flipbook Viewer Styles
   ========================================== */
.viewer-body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 3 독서 테마 설정 (Viewer Themes) */
.theme-light {
  background: var(--bg-light);
  color: var(--text-light);
}
.theme-light .viewer-toolbar,
.theme-light .sidebar-panel,
.theme-light .search-overlay,
.theme-light .thumbnail-overlay,
.theme-light .themes-panel {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
  color: #2c2c2e;
}
.theme-light .toolbar-btn {
  color: #555;
}
.theme-light .toolbar-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #000;
}
.theme-light .divider-tab {
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}

.theme-dark {
  background: var(--bg-dark);
  color: var(--text-dark);
}
.theme-dark .viewer-toolbar,
.theme-dark .sidebar-panel,
.theme-dark .search-overlay,
.theme-dark .thumbnail-overlay,
.theme-dark .themes-panel {
  background: rgba(20, 22, 35, 0.85);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  color: #f2f2f7;
}
.theme-dark .toolbar-btn {
  color: #bbb;
}
.theme-dark .toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.theme-dark .divider-tab {
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.theme-sepia {
  background: var(--bg-sepia);
  color: var(--text-sepia);
}
.theme-sepia .viewer-toolbar,
.theme-sepia .sidebar-panel,
.theme-sepia .search-overlay,
.theme-sepia .thumbnail-overlay,
.theme-sepia .themes-panel {
  background: rgba(244, 236, 216, 0.9);
  border-color: rgba(95, 75, 50, 0.15);
  box-shadow: 0 8px 32px rgba(95, 75, 50, 0.08);
  color: #5f4b32;
}
.theme-sepia .toolbar-btn {
  color: #7d6549;
}
.theme-sepia .toolbar-btn:hover {
  background: rgba(95, 75, 50, 0.06);
  color: #40301d;
}
.theme-sepia .divider-tab {
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

/* Viewer Container & Page-Flip viewport */
.viewer-container {
  flex-grow: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 60px; /* Leave space for left/right tabs */
  overflow: hidden;
}

.book-viewport {
  width: 100%;
  height: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1000px;
}

.book-container {
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  background: #fff;
  transition: transform 0.2s cubic-bezier(0.1, 0.8, 0.2, 1);
  transform-origin: center center;
}

/* Pages Styling & Hardcover Effects */
.page {
  background-color: #fff;
  box-shadow: inset 3px 0 10px rgba(0, 0, 0, 0.05);
  position: relative;
}

.page-content {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.canvas-wrapper {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
}

.page-num-indicator {
  position: absolute;
  bottom: 12px;
  font-size: 11px;
  color: #8e8e93;
  width: 100%;
  text-align: center;
  pointer-events: none;
}

/* Front & Back Hardcovers */
.hardcover-front {
  background: linear-gradient(135deg, #1c1a27 0%, #0d0c12 100%) !important;
  box-shadow: inset 1px 1px 3px rgba(255, 255, 255, 0.2), inset -10px 0 20px rgba(0,0,0,0.5) !important;
}

.hardcover-back {
  background: linear-gradient(135deg, #0d0c12 0%, #1c1a27 100%) !important;
  box-shadow: inset 1px 1px 3px rgba(255, 255, 255, 0.2), inset 10px 0 20px rgba(0,0,0,0.5) !important;
}

/* PDF.js Text Layer overlay (Select & Copy support) */
.textLayer {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  opacity: 0.2; /* Visible selection but transparent characters */
  line-height: 1.0;
  pointer-events: auto;
}

.textLayer span {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}

.textLayer ::selection {
  background: var(--primary-glow);
}

/* Search Highlights */
.search-highlight {
  position: absolute;
  background: transparent;
  pointer-events: none;
}

.highlight-yellow {
  background-color: rgba(255, 223, 0, 0.4);
  border: 1px solid rgba(255, 223, 0, 0.7);
  border-radius: 2px;
  box-shadow: 0 0 5px rgba(255, 223, 0, 0.6);
  color: transparent;
}

/* ==========================================
   E. Dynamic Divider Tabs (세로 인덱스 탭)
   ========================================== */
.divider-tabs-container {
  position: absolute;
  top: 0;
  height: 100%;
  width: 40px;
  z-index: 50;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.left-tabs {
  left: 10px;
}

.right-tabs {
  right: 10px;
}

/* Tab visual style */
.divider-tab {
  position: absolute;
  pointer-events: auto;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 12px 8px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  border-width: 1px;
  border-style: solid;
}

.left-tabs .divider-tab {
  right: 0;
  border-radius: 6px 0 0 6px;
  border-right: none;
  transform: translateX(0);
}

.left-tabs .divider-tab:hover {
  transform: translateX(-4px);
}

.right-tabs .divider-tab {
  left: 0;
  border-radius: 0 6px 6px 0;
  border-left: none;
  transform: translateX(0);
}

.right-tabs .divider-tab:hover {
  transform: translateX(4px);
}

.tab-label {
  display: inline-block;
  transform: rotate(0deg);
  white-space: nowrap;
}

/* Hiding tabs animation for fullscreen/mobile */
.hidden-tabs {
  opacity: 0 !important;
  pointer-events: none;
}

.left-tabs.hidden-tabs {
  transform: translate(-100%, -50%) !important;
}

.right-tabs.hidden-tabs {
  transform: translate(100%, -50%) !important;
}

/* ==========================================
   F. Viewer Interfaces & Toolbars
   ========================================== */

/* Top Search Overlay */
.search-overlay {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  transition: transform 0.3s ease;
}

.search-overlay.hidden-toolbar {
  transform: translateX(-50%) translateY(-100px);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: inherit;
  font-size: 14px;
  width: 200px;
}

.search-count {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.7;
  margin-right: 5px;
}

/* Bottom Toolbar */
.viewer-toolbar {
  height: 56px;
  border-top: 1px solid var(--border-light);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateY(0);
}

.viewer-toolbar.hidden-toolbar {
  transform: translateY(100%);
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.toolbar-btn.active {
  background: var(--primary-glow);
  color: var(--primary);
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: rgba(0, 0, 0, 0.1);
}

.theme-dark .toolbar-divider {
  background: rgba(255, 255, 255, 0.1);
}

.page-input-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.page-input-container input {
  width: 48px;
  text-align: center;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 6px;
  padding: 4px;
  color: inherit;
  font-weight: bold;
}

.theme-dark .page-input-container input {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255,255,255,0.1);
}

/* Sidebar Panel */
.sidebar-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 320px;
  height: 100%;
  z-index: 150;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  animation: slideRight 0.3s ease-out;
}

@keyframes slideRight {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.sidebar-header {
  padding: 15px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-tabs {
  display: flex;
  gap: 5px;
}

.sidebar-tab-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: inherit;
  opacity: 0.6;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sidebar-tab-btn.active {
  opacity: 1;
  background: rgba(88, 86, 214, 0.15);
  color: var(--primary);
}

.sidebar-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 15px;
}

.tab-content {
  display: none;
  height: 100%;
}

.tab-content.active {
  display: block;
}

.sidebar-list {
  list-style: none;
}

.sidebar-list li {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 8px;
  font-size: 13px;
}

.sidebar-list li:hover {
  background: rgba(0, 0, 0, 0.04);
}

.theme-dark .sidebar-list li:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* TOC & Search item styles */
.sidebar-toc-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toc-color-marker {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.toc-title {
  flex-grow: 1;
  font-weight: 500;
}

.toc-page {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.6;
}

.sidebar-search-bar {
  margin-bottom: 15px;
}

.sidebar-search-bar input {
  width: 100%;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 8px;
  padding: 8px 12px;
  color: inherit;
  font-size: 13px;
}

.theme-dark .sidebar-search-bar input {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
}

.sidebar-search-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-item-snippet {
  font-size: 12px;
  opacity: 0.7;
}

.sidebar-search-item.active {
  background: var(--primary-glow);
}

/* Bookmarks Sidebar elements */
.bookmark-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
}

.bookmark-add-row input {
  flex-grow: 1;
  background: rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: inherit;
}

.theme-dark .bookmark-add-row input {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
}

.sidebar-bookmark-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bookmark-item-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-grow: 1;
}

.bookmark-note-text {
  font-size: 12px;
  opacity: 0.8;
}

.bookmark-time {
  font-size: 10px;
  opacity: 0.5;
}

.sidebar-info-item {
  text-align: center;
  padding: 40px 10px !important;
  opacity: 0.5;
}

/* Thumbnail Grid Overlay styling */
.thumbnail-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 200;
  display: flex;
  flex-direction: column;
  animation: cardFadeIn 0.3s ease-out;
}

.thumbnail-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.thumbnail-grid {
  flex-grow: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 20px;
  padding: 30px;
}

.thumbnail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.thumb-canvas-container {
  width: 90px;
  height: 128px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  border: 1px solid rgba(0,0,0,0.05);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s;
}

.thumbnail-item:hover .thumb-canvas-container {
  transform: translateY(-4px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.2);
}

.thumbnail-item canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-page-num {
  font-size: 11px;
  font-weight: bold;
}

/* Themes Panel Style */
.themes-panel {
  position: absolute;
  bottom: 65px;
  left: 20px;
  z-index: 100;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 250px;
}

.themes-panel h4 {
  font-size: 13px;
  font-weight: bold;
}

.theme-buttons {
  display: flex;
  gap: 8px;
}

.btn-theme {
  flex-grow: 1;
  padding: 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

.btn-theme.active {
  box-shadow: 0 0 0 2px var(--primary);
}

/* Document Loading spinner */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #090a0f;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.loading-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  width: 100%;
  max-width: 320px;
}

.loading-content h2 {
  font-size: 18px;
  font-weight: bold;
}

.loading-content p {
  font-size: 12px;
  color: #8e8e93;
}

.loading-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #30d158);
  border-radius: 3px;
  transition: width 0.2s ease;
}

/* ==========================================
   G. Mobile Responsive Adjustments (여백 제로화)
   ========================================== */
@media (max-width: 768px) {
  /* CMS adjustments */
  .cms-body {
    padding: 0;
  }
  
  .dashboard-layout {
    flex-direction: column;
  }
  
  .dashboard-sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border-dark);
    padding: 15px 20px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  }
  
  .sidebar-brand {
    margin-bottom: 0;
  }
  
  .sidebar-nav {
    display: none;
  }
  
  .sidebar-footer {
    flex-direction: row;
    align-items: center;
    border-top: none;
    padding-top: 0;
    gap: 15px;
  }
  
  .user-profile {
    display: none;
  }
  
  .dashboard-main {
    margin-left: 0;
    width: 100%;
    padding: 20px;
    gap: 20px;
  }
  
  .main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .stats-summary-grid {
    grid-template-columns: 1fr;
  }

  /* 1. Mobile E-Book Zero Margin Layout & Fit */
  .viewer-container {
    padding: 0 !important; /* Zero margins */
  }

  .book-viewport {
    width: 100%;
    height: 100%;
  }

  .book-container {
    box-shadow: none; /* Flat style for seamless mobile fit */
    border-radius: 0;
  }

  /* Hide vertical dividers on mobile to maximize page width */
  .divider-tabs-container {
    display: none !important;
  }

  .sidebar-panel {
    width: 100%; /* Cover entire mobile screen */
  }

  /* Autoplay position adjustments */
  .themes-panel {
    left: 10px;
    bottom: 60px;
    width: calc(100% - 20px);
  }
}

/* Print CSS */
@media print {
  body * {
    visibility: hidden;
  }
  #book-container, #book-container * {
    visibility: visible;
  }
  #book-container {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
  .viewer-toolbar, .divider-tabs-container, .sidebar-panel, .search-overlay {
    display: none !important;
  }
}
