
:root {
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --secondary-gradient: linear-gradient(135deg, #ec4899 0%, #f43f5e 100%);
  --bg-home: #0f172a;
  --text-home: #f1f5f9;
  --card-bg: rgba(30, 41, 59, 0.7);
  --card-border: rgba(255, 255, 255, 0.08);
}

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

body {
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
}

/* Glassmorphism Lock Screen */
.lock-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.5s;
  opacity: 1;
  visibility: visible;
}

.lock-screen-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.lock-screen-card {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 3rem 2.5rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  animation: scaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.lock-screen-header {
  margin-bottom: 2rem;
}

.lock-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  animation: pulse 2.5s infinite ease-in-out;
  display: inline-block;
}

.lock-screen-card h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  color: #fff;
  letter-spacing: -0.02em;
}

.lock-screen-card p {
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.6;
}

@keyframes scaleIn {
  from { transform: scale(0.9) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.4)); }
  100% { transform: scale(1); }
}

/* Home Page Portal */
.home-body {
  background: radial-gradient(circle at top right, #1e1b4b, #0f172a 60%);
  color: var(--text-home);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.home-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 2rem;
  flex: 1;
}

header.home-header {
  text-align: center;
  margin-bottom: 5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.portal-top-bar {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  max-width: 1200px;
  margin-bottom: 2rem;
}

header.home-header h1 {
  font-size: 3.5rem;
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
  letter-spacing: -0.05em;
}

header.home-header p {
  color: #94a3b8;
  font-size: 1.25rem;
  max-width: 600px;
  margin: 0 auto;
}

.novel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 3rem;
}

.novel-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(16px);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease;
  position: relative;
  overflow: hidden;
}

.novel-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--primary-gradient);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.novel-card:hover {
  transform: translateY(-8px);
  border-color: rgba(99, 102, 241, 0.4);
}

.novel-card:hover::before {
  opacity: 1;
}

.novel-card:nth-child(even)::before {
  background: var(--secondary-gradient);
}

.novel-card:nth-child(even):hover {
  border-color: rgba(236, 72, 153, 0.4);
}

.novel-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 0.35rem 1rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.novel-card:nth-child(even) .novel-badge {
  background: rgba(236, 72, 153, 0.15);
  color: #f472b6;
}

.novel-card h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.novel-desc {
  color: #94a3b8;
  font-size: 1.05rem;
  margin-bottom: 2rem;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.novel-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
  color: #64748b;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.novel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-gradient);
  color: white;
  text-decoration: none;
  font-weight: 600;
  padding: 1rem 2rem;
  border-radius: 14px;
  transition: filter 0.3s ease, transform 0.2s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.novel-card:nth-child(even) .novel-btn {
  background: var(--secondary-gradient);
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.novel-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.02);
}

/* Footer */
footer.site-footer {
  text-align: center;
  padding: 3rem 0;
  color: #475569;
  font-size: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: auto;
}

/* Detail Page & Tabs */
.back-home {
  display: inline-flex;
  align-items: center;
  color: #94a3b8;
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 2rem;
  transition: color 0.2s ease;
}

.back-home:hover {
  color: #f1f5f9;
}

.tabs-header {
  display: flex;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 2.5rem;
  padding-bottom: 0.5rem;
}

.tab-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.tab-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: #fff;
  background: var(--primary-gradient);
}

.tab-content {
  display: none;
  animation: fadeIn 0.4s ease forwards;
}

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

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

/* Chapter List Grid */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.chapter-link-card {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 1.5rem;
  text-decoration: none;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.chapter-link-card:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-4px);
}

.chapter-num {
  font-size: 0.85rem;
  color: #818cf8;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.chapter-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.chapter-wordcount {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: auto;
}

/* Reader View Styles */
body.reader-body {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Theme Configurations */
body.theme-light {
  background-color: #fcfcfc;
  color: #1a1a1a;
}
body.theme-light .reader-nav,
body.theme-light .reader-sidebar {
  background: #f5f5f7;
  border-color: #e5e5ea;
}
body.theme-light .control-btn {
  background: #e5e5ea;
  color: #333;
}

body.theme-sepia {
  background-color: #fbf0e3;
  color: #433422;
}
body.theme-sepia .reader-nav,
body.theme-sepia .reader-sidebar {
  background: #f3dfca;
  border-color: #e1cab3;
}
body.theme-sepia .control-btn {
  background: #ecd2b9;
  color: #5c4327;
}

body.theme-dark {
  background-color: #121824;
  color: #cbd5e1;
}
body.theme-dark .reader-nav,
body.theme-dark .reader-sidebar {
  background: #1e293b;
  border-color: rgba(255,255,255,0.06);
}
body.theme-dark .control-btn {
  background: #334155;
  color: #cbd5e1;
}

body.theme-deepdark {
  background-color: #000000;
  color: #8e8e93;
}
body.theme-deepdark .reader-nav,
body.theme-deepdark .reader-sidebar {
  background: #151515;
  border-color: #262626;
}
body.theme-deepdark .control-btn {
  background: #262626;
  color: #8e8e93;
}

/* Font Choices */
.font-serif {
  font-family: "PingFang TC", "Songti TC", "Noto Serif TC", "PMingLiU", serif;
}
.font-sans {
  font-family: "SF Pro TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
}

/* Font Size Modifiers */
.size-sm p { font-size: 1.0rem; margin-bottom: 1.5rem; }
.size-md p { font-size: 1.15rem; margin-bottom: 1.75rem; }
.size-lg p { font-size: 1.3rem; margin-bottom: 2.0rem; }
.size-xl p { font-size: 1.5rem; margin-bottom: 2.25rem; }

/* Progress bar */
.progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: transparent;
  z-index: 1000;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary-gradient);
  transition: width 0.1s ease;
}

/* Nav bar */
.reader-nav {
  position: fixed;
  top: 4px;
  left: 0;
  width: 100%;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  box-shadow: 0 1px 10px rgba(0,0,0,0.05);
  z-index: 900;
}

.reader-title-area {
  display: flex;
  flex-direction: column;
}
.reader-nav-novel {
  font-size: 0.8rem;
  color: #888;
}
.reader-nav-chap {
  font-size: 1.1rem;
  font-weight: 700;
}

.reader-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.control-group {
  display: flex;
  gap: 0.25rem;
}

.control-btn {
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.control-btn:hover {
  opacity: 0.8;
}
.control-btn.active {
  background: #6366f1 !important;
  color: white !important;
}

/* Reader layout */
.reader-layout {
  display: flex;
  max-width: 1400px;
  margin: 68px auto 0 auto;
}

.reader-sidebar {
  width: 280px;
  height: calc(100vh - 68px);
  position: sticky;
  top: 68px;
  padding: 2rem;
  overflow-y: auto;
}

.reader-sidebar h3 {
  font-size: 1rem;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
}

.sidebar-menu {
  list-style: none;
}

.sidebar-menu li {
  margin-bottom: 0.75rem;
}

.sidebar-menu a {
  text-decoration: none;
  color: inherit;
  font-size: 0.95rem;
  opacity: 0.7;
  transition: opacity 0.2s ease, padding-left 0.2s ease;
  display: block;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
  opacity: 1;
  padding-left: 0.5rem;
  color: #6366f1;
}

.reader-main {
  flex: 1;
  padding: 4rem 3rem;
  max-width: 800px;
  margin: 0 auto;
}

.reader-header {
  margin-bottom: 3.5rem;
  border-bottom: 1px solid rgba(128,128,128,0.1);
  padding-bottom: 2rem;
}

.reader-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
}

.reader-meta-info {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
  color: #888;
}

/* Styled introductory quotes */
.reader-intro-quote {
  background: rgba(128,128,128,0.05);
  border-left: 4px solid #6366f1;
  padding: 1.5rem;
  margin-bottom: 3rem;
  border-radius: 0 12px 12px 0;
}
.reader-intro-quote p {
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.8;
  margin-bottom: 0 !important;
}

/* Summary Box */
.reader-summary-box {
  background: rgba(128,128,128,0.03);
  border: 1px dashed rgba(128,128,128,0.15);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 3rem;
}
.reader-summary-box h4 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: #6366f1;
}
.reader-summary-box ul {
  list-style-type: none;
  padding-left: 0.5rem;
}
.reader-summary-box li {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

/* Text Content Rendering */
.reader-content p {
  line-height: 2.0;
  text-indent: 2em;
  letter-spacing: 0.02em;
}

/* Chapter pagination */
.reader-pagination {
  display: flex;
  justify-content: space-between;
  margin-top: 5rem;
  border-top: 1px solid rgba(128,128,128,0.1);
  padding-top: 3rem;
}

.pagination-btn {
  display: inline-flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  max-width: 45%;
}

.pagination-btn span.label {
  font-size: 0.8rem;
  color: #888;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.pagination-btn span.title {
  font-weight: 700;
  font-size: 1.1rem;
}

.pagination-btn.next {
  text-align: right;
  align-items: flex-end;
}

/* Markdown parsing tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
}
th, td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(128,128,128,0.15);
  text-align: left;
}
th {
  font-weight: 700;
  background-color: rgba(128,128,128,0.05);
}
.table-responsive {
  overflow-x: auto;
}

/* Sidebar toggle on mobile */
@media (max-width: 1024px) {
  .reader-sidebar {
    display: none;
  }
  .reader-main {
    padding: 3rem 1.5rem;
  }
}
@media (max-width: 768px) {
  .reader-nav {
    padding: 0 1rem;
    height: auto;
    flex-direction: column;
    padding-bottom: 0.75rem;
  }
  .reader-controls {
    margin-top: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
  }
  .reader-layout {
    margin-top: 110px;
  }
  .reader-sidebar {
    display: none;
  }
  header.home-header h1 {
    font-size: 2.5rem;
  }
  .novel-grid {
    grid-template-columns: 1fr;
  }
}
