:root {
  /* WebNovels Design System Tokens (design.md Section 7) */
  --color-brand-primary: #6d5ef5;
  --color-brand-secondary: #8b7cf6;
  --color-brand-gradient: linear-gradient(135deg, #6d5ef5 0%, #8b7cf6 100%);

  --bg-main: #090d16;
  --bg-surface: #111827;
  --bg-panel: rgba(17, 24, 39, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-amber: #f59e0b;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;

  --font-ui: 'Pretendard', 'Noto Sans KR', sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-reader: 'Noto Serif KR', serif;

  --header-height: 64px;
  --bottom-nav-height: 64px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

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

body {
  font-family: var(--font-ui);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header (WebNovels Branding) */
.webnovels-header {
  height: var(--header-height);
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-symbol {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--color-brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 15px rgba(109, 94, 245, 0.4);
}

.brand-text {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-highlight {
  color: var(--color-brand-secondary);
}

/* Desktop Navigation */
.desktop-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
}

.nav-highlight {
  color: #a7f3d0;
  font-weight: 600;
}

.nav-admin {
  color: #f472b6;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Button System (design.md Section 14) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  outline: none;
  transition: all 0.2s ease;
  background-color: transparent;
  color: var(--text-primary);
  text-decoration: none;
  user-select: none;
}

.btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
}

.btn-hero, .btn-primary {
  background: var(--color-brand-gradient) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 4px 20px rgba(109, 94, 245, 0.4) !important;
}

.btn-hero:hover, .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(109, 94, 245, 0.6) !important;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  backdrop-filter: blur(10px);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.15) !important;
  border-color: rgba(255, 255, 255, 0.4) !important;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05) !important;
  color: var(--text-primary) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12) !important;
}

.btn-icon {
  padding: 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #ffffff !important;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 12px 26px;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  color: #ffffff !important;
}

/* Container & Sections */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

.section-padding {
  padding-top: 30px;
  padding-bottom: 30px;
}

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

.section-header h3, .section-header h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-more {
  color: var(--color-brand-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
}

/* Main Views Switcher */
.main-view {
  display: none;
  animation: fadeIn 0.3s ease;
}
.main-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero Carousel */
.hero-carousel-wrapper {
  position: relative;
  height: 380px;
  overflow: hidden;
  border-bottom: 1px solid var(--border-color);
}

.hero-slide {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
}

.hero-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-size: cover;
  background-position: center;
  filter: blur(20px) brightness(0.4);
}

.hero-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(9, 13, 22, 0.4) 0%, #090d16 100%);
}

.hero-content {
  position: relative;
  z-index: 10;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 40px;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: 2.4rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.hero-desc {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin-bottom: 16px;
}

.hero-tags span {
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 12px;
  border-radius: 16px;
  margin-right: 6px;
  color: var(--text-secondary);
}

.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-accent {
  background: rgba(109, 94, 245, 0.2);
  color: var(--color-brand-secondary);
  border: 1px solid rgba(109, 94, 245, 0.4);
}

.badge-outline {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-primary {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

/* Modals & Dialogs */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.active {
  display: flex;
}

.modal-dialog {
  width: 90%;
  max-width: 500px;
  padding: 30px;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

.dialog-ad {
  max-width: 440px;
}

.ad-unlock-icon {
  font-size: 3rem;
  margin-bottom: 10px;
}

.ad-video-sim {
  padding: 30px;
  background: #000;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  color: var(--color-brand-secondary);
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.pulse-icon {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

.toast-container {
  position: fixed;
  bottom: 80px; right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast-msg {
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid var(--color-brand-primary);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  font-size: 0.9rem;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.continue-reading-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.continue-reading-card:hover {
  transform: translateY(-2px);
}

.continue-thumb {
  width: 60px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.continue-info {
  flex: 1;
}

.continue-info h4 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-brand-gradient);
  border-radius: 4px;
}

.progress-text {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Works Card Grid */
.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.work-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.work-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(109, 94, 245, 0.25);
  border-color: rgba(109, 94, 245, 0.4);
}

.cover-wrapper {
  position: relative;
  width: 100%;
  padding-top: 140%; /* aspect ratio */
  overflow: hidden;
}

.cover-img {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover;
}

.card-badge {
  position: absolute;
  top: 10px; left: 10px;
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.card-info {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.3;
}

.card-author {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* 16-Menu Sub-Admin Permission Control Matrix Grid */
.permission-matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.perm-switch-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
  user-select: none;
}

.perm-switch-card:hover {
  background: rgba(109, 94, 245, 0.15);
  border-color: rgba(109, 94, 245, 0.4);
}

.perm-switch-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-brand-primary);
  cursor: pointer;
}

/* 16-Menu Sub-Bar Navbar */
.admin-16menu-nav-bar {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.menu-16-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}

.menu-16-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-16-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  stroke: currentColor;
}

.menu-16-item:hover, .menu-16-item.active {
  background: var(--color-brand-gradient);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(109, 94, 245, 0.3);
}

.style-danger {
  border-color: rgba(244, 63, 94, 0.4) !important;
  color: var(--accent-rose) !important;
}

.style-danger:hover {
  background: rgba(244, 63, 94, 0.2) !important;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Work Detail Hero */
.work-detail-hero {
  display: flex;
  gap: 30px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  padding: 30px;
  border-radius: var(--radius-lg);
}

.detail-cover-box img {
  width: 200px;
  height: 280px;
  object-fit: cover;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.detail-info-box {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.detail-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  margin: 10px 0 6px;
}

.detail-author {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.detail-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 24px;
}

.detail-actions {
  display: flex;
  gap: 12px;
  margin-top: auto;
}

/* Episode Row */
.episode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.episode-row:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(109, 94, 245, 0.3);
}

.ep-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ep-number {
  font-weight: 700;
  color: var(--color-brand-secondary);
  min-width: 40px;
}

.ep-title {
  font-size: 0.95rem;
  font-weight: 600;
}

/* Fullscreen Reader (design.md Section 26~29) */
.full-screen-reader {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 500;
  overflow-y: auto;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.reader-header {
  position: sticky;
  top: 0;
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 10;
}

.reader-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.reader-paper {
  font-family: var(--font-reader);
  line-height: 1.8;
  font-size: 18px;
}

.ep-heading {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  margin-bottom: 30px;
  text-align: center;
}

.ep-content p {
  margin-bottom: 1.4em;
  text-indent: 1em;
}

.author-comment-box {
  margin-top: 50px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.reader-bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 40px;
}

/* Reader Themes */
.theme-light {
  background-color: #fafaf7 !important;
  color: #242424 !important;
}
.theme-light .reader-header {
  background: rgba(250, 250, 247, 0.9) !important;
  color: #242424 !important;
  border-color: #e5e5e0 !important;
}

.theme-sepia {
  background-color: #f3ebdd !important;
  color: #40372f !important;
}
.theme-sepia .reader-header {
  background: rgba(243, 235, 221, 0.9) !important;
  color: #40372f !important;
  border-color: #dcd0c0 !important;
}

.theme-dark {
  background-color: #111111 !important;
  color: #eaeaea !important;
}

/* Mobile Bottom Navigation (design.md Section 4.1) */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: rgba(9, 13, 22, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  z-index: 200;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.72rem;
}
.bottom-nav-item.active {
  color: var(--color-brand-primary);
}

/* Filter Pills */
.filter-pills {
  display: flex;
  gap: 10px;
  overflow-x: auto;
}

.pill {
  padding: 8px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.pill.active {
  background: var(--color-brand-primary);
  color: #fff;
  border-color: var(--color-brand-primary);
}

/* Sticky Bottom CTA for Mobile */
.sticky-bottom-cta {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 12px 20px;
  background: rgba(9, 13, 22, 0.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  gap: 12px;
  z-index: 150;
}

/* Ad Banner Card */
.ad-unlock-banner-card {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  padding: 40px;
  border-radius: var(--radius-lg);
  color: #fff;
  text-align: center;
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
}

.banner-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 12px;
}

/* Amount Title in Creator Studio */
.amount-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  margin: 8px 0;
}
.text-indigo { color: #818cf8; }
.text-emerald { color: #34d399; }
.text-amber { color: #fbbf24; }

/* Responsive Breakpoints (design.md Section 5) */
@media (max-width: 768px) {
  .desktop-nav { display: none; }
  .mobile-bottom-nav { display: flex; }
  .work-detail-hero { flex-direction: column; text-align: center; }
  .detail-cover-box img { width: 140px; height: 200px; margin: 0 auto; }
  .detail-actions { display: none; }
  .sticky-bottom-cta { display: flex; }
  .webnovels-body { padding-bottom: var(--bottom-nav-height); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .menu-16-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2-col { grid-template-columns: 1fr; }
}

/* ---- Admin Dashboard KPI Cards ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.kpi-card {
  padding: 20px;
  text-align: center;
  border-radius: var(--radius-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(109, 94, 245, 0.2);
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.kpi-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--color-brand-primary);
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
  color: #fff;
  line-height: 1.1;
}

.kpi-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---- Admin Input Style ---- */
.admin-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  transition: border-color 0.2s ease;
}

.admin-input:focus {
  outline: none;
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 3px rgba(109, 94, 245, 0.15);
}

/* ---- Loading Spinner ---- */
.admin-loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 12px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(109, 94, 245, 0.2);
  border-top-color: var(--color-brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
