:root { --font-size: 18px; }

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

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: #f5f0eb;
  color: #333;
  transition: background 0.3s, color 0.3s;
}

body.dark {
  background: #1a1a2e;
  color: #e0e0e0;
}

a { text-decoration: none; color: inherit; }

/* ===== SITE HEADER ===== */
.site-header {
  background: #2c2c2c;
  color: #fff;
  padding: 20px 40px;
  text-align: center;
}
.site-header h1 { font-size: 28px; }

/* ===== BOOKSHELF ===== */
.bookshelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  padding: 40px;
  max-width: 1200px;
  margin: 0 auto;
}

.novel-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: transform 0.2s, box-shadow 0.2s;
}
.novel-card:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(0,0,0,0.15); }
.novel-card a { display: flex; flex-direction: column; height: 100%; }

.cover-wrap {
  width: 100%;
  height: 200px;
  background: #ccc;
  overflow: hidden;
}
.cover-wrap img { width: 100%; height: 100%; object-fit: cover; }

.card-info { padding: 16px; flex: 1; }
.card-info h2 { font-size: 18px; margin-bottom: 8px; color: #222; }
.card-info .author { font-size: 13px; color: #666; margin-bottom: 4px; }
.card-info .status { font-size: 13px; color: #888; margin-bottom: 8px; }
.card-info .desc { font-size: 14px; color: #555; line-height: 1.5; }

body.dark .novel-card { background: #2a2a3e; }
body.dark .card-info h2 { color: #e0e0e0; }
body.dark .card-info .desc { color: #aaa; }

/* ===== NOVEL PAGE ===== */
.novel-header {
  background: #2c2c2c;
  color: #fff;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.back-btn {
  color: #aaa;
  font-size: 14px;
  white-space: nowrap;
}
.back-btn:hover { color: #fff; }

.novel-info {
  display: flex;
  gap: 32px;
  padding: 32px 40px;
  max-width: 900px;
  margin: 0 auto;
}
.novel-cover-wrap {
  flex-shrink: 0;
  width: 160px;
  height: 220px;
  background: #ccc;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.novel-cover-wrap img { width: 100%; height: 100%; object-fit: cover; }
.novel-meta { flex: 1; }
.novel-meta p { margin-bottom: 8px; font-size: 15px; }
.novel-desc { color: #666; line-height: 1.7; }

.toc-section {
  max-width: 900px;
  margin: 0 auto 40px;
  padding: 0 40px;
}
.toc-section h2 {
  font-size: 20px;
  border-bottom: 2px solid #ddd;
  padding-bottom: 10px;
  margin-bottom: 16px;
}
.toc-list { list-style: none; }
.toc-list li { border-bottom: 1px solid #eee; }
.toc-list li a {
  display: block;
  padding: 12px 8px;
  font-size: 15px;
  color: #333;
  transition: background 0.15s;
}
.toc-list li a:hover { background: #f0ebe4; padding-left: 16px; }

body.dark .toc-list li a { color: #ddd; }
body.dark .toc-list li a:hover { background: #2a2a3e; }

/* ===== CHAPTER PAGE ===== */
.chapter-page {
  display: flex;
  min-height: 100vh;
}

.chapter-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid #ddd;
  padding: 16px;
  z-index: 100;
}
body.dark .chapter-sidebar { background: #1e1e30; border-color: #333; }

.chapter-sidebar .sidebar-title {
  font-size: 13px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.chapter-sidebar a {
  display: block;
  padding: 8px 6px;
  font-size: 13px;
  color: #555;
  border-radius: 4px;
  margin-bottom: 2px;
  transition: background 0.15s;
}
.chapter-sidebar a:hover { background: #f0ebe4; color: #333; }
.chapter-sidebar a.active { background: #e8d5b7; color: #333; font-weight: bold; }
body.dark .chapter-sidebar a { color: #aaa; }
body.dark .chapter-sidebar a.active { background: #3a3a5a; color: #fff; }

.chapter-main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chapter-topbar {
  position: sticky;
  top: 0;
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 10px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 50;
}
body.dark .chapter-topbar { background: #1a1a2e; border-color: #333; }

.progress-track {
  flex: 1;
  height: 4px;
  background: #eee;
  border-radius: 2px;
  overflow: hidden;
}
.progress-track .progress-bar {
  height: 100%;
  background: #c9a96e;
  width: 0%;
  transition: width 0.1s;
}
.progress-pct { font-size: 12px; color: #999; min-width: 36px; }

.font-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.font-controls button {
  background: #f0ebe4;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
}
.font-controls button:hover { background: #e0d5c4; }

.dark-toggle {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
}
.dark-toggle:hover { background: #eee; }
body.dark .dark-toggle { border-color: #555; color: #ddd; }
body.dark .dark-toggle:hover { background: #333; }

.chapter-content {
  max-width: 720px;
  margin: 40px auto;
  padding: 0 32px;
  font-size: var(--font-size);
  line-height: 1.9;
}
.chapter-content h1 { font-size: 24px; margin-bottom: 32px; color: #222; }
.chapter-content p { margin-bottom: 1.5em; text-indent: 2em; }
body.dark .chapter-content h1 { color: #e0e0e0; }

.chapter-nav {
  display: flex;
  justify-content: space-between;
  padding: 24px 32px;
  max-width: 720px;
  margin: 0 auto 40px;
}
.chapter-nav a {
  background: #2c2c2c;
  color: #fff;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 14px;
  transition: background 0.2s;
}
.chapter-nav a:hover { background: #444; }
.chapter-nav a.disabled {
  background: #ccc;
  color: #999;
  pointer-events: none;
}

.loading { text-align: center; padding: 40px; color: #999; }
