:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #191d2b;
  --text-muted: #5b6080;
  --accent: #4666ff;
  --accent2: #ffb94a;
  --border: #e4e7f1;
  --hover: rgba(70,102,255,0.09);
  --danger: #e14e5b;
  --round: 11px;
}

body.theme-dark {
  --bg: #101221;
  --surface: #181b2d;
  --text: #e6eaf3;
  --text-muted: #9196b3;
  --accent: #6b89ff;
  --accent2: #ffd166;
  --border: #262b44;
  --hover: rgba(107,137,255,0.08);
}

body.theme-sepia {
  --bg: #f4f1e8;
  --surface: #fdf8f0;
  --text: #5c4b37;
  --text-muted: #8b7355;
  --accent: #b8860b;
  --accent2: #cd853f;
  --border: #d2c5aa;
  --hover: rgba(184,134,11,0.08);
}

body.theme-night {
  --bg: #0a0a0a;
  --surface: #1a1a1a;
  --text: #e0e0e0;
  --text-muted: #a0a0a0;
  --accent: #00d4aa;
  --accent2: #ff6b6b;
  --border: #333;
  --hover: rgba(0,212,170,0.08);
}

body.reading-mode::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: rgba(168,120,68,0.15);
  mix-blend-mode: multiply;
  z-index: 999999;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family, 'Inter', sans-serif);
  font-size: var(--font-size, 16px);
  min-height: 100vh;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

#main-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  padding: 30px;
  border-radius: var(--round);
  max-width: 400px;
  width: 100%;
  text-align: center;
  border: 1px solid var(--border);
}

.modal-content h2 {
  margin-top: 0;
  color: var(--accent);
}

.error-message {
  color: var(--danger);
  font-size: 14px;
  margin: 10px 0;
}

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-main { 
  font-size: 26px; 
  font-weight: 800; 
  color: var(--accent); 
  text-decoration: none; 
}

.nav { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
}

.classic-nav { display: flex; }

.hamburger-btn { display: none; }

.nav-link {
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s;
  white-space: nowrap;
}

.nav-link:hover, .nav-link.active { 
  background: var(--hover); 
  color: var(--accent); 
}

.icon-btn {
  background: transparent; 
  border: none; 
  font-size: 20px; 
  cursor: pointer;
  padding: 8px; 
  border-radius: 8px; 
  transition: background 0.2s;
}

.icon-btn:hover { background: var(--hover); }

.dropdown { position: relative; }

.dropdown-menu {
  position: absolute; 
  top: calc(100% + 6px); 
  right: 0;
  background: var(--surface); 
  border: 1px solid var(--border);
  border-radius: var(--round); 
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  min-width: 280px; 
  display: none; 
  z-index: 200;
  max-height: 400px;
  overflow-y: auto;
}

.dropdown-menu.show { display: block; }

.dropdown-header { 
  padding: 12px 16px; 
  border-bottom: 1px solid var(--border); 
}

.dropdown-item {
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  padding: 10px 16px; 
  cursor: pointer; 
  transition: background 0.2s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--text);
}

.dropdown-item:hover { background: var(--hover); }

.dropdown-divider { 
  height: 1px; 
  background: var(--border); 
  margin: 4px 0; 
}

.dropdown-section { padding: 12px 16px; }

.dropdown-item-label {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  font-size: 14px;
}

.theme-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
}

.theme-btn:hover {
  background: var(--hover);
  border-color: var(--accent);
}

.theme-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.settings-select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.font-size-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.font-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: bold;
}

.font-btn:hover {
  background: var(--hover);
  border-color: var(--accent);
}

#font-size-display, #ham-font-size-display {
  font-size: 14px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: center;
}

.toggle { 
  position: relative; 
  display: inline-block; 
  width: 44px; 
  height: 24px; 
}

.toggle input { 
  opacity: 0; 
  width: 0; 
  height: 0; 
}

.toggle-slider {
  position: absolute; 
  inset: 0; 
  background: var(--border); 
  transition: 0.3s;
  border-radius: 24px;
}

.toggle-slider:before {
  content: ""; 
  position: absolute; 
  height: 18px; 
  width: 18px;
  left: 3px; 
  bottom: 3px; 
  background: white; 
  transition: 0.3s; 
  border-radius: 50%;
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }

.container-wide {
  max-width: 1280px; 
  margin: 0 auto; 
  padding: 0 20px;
}

.section { 
  padding: 32px 0;
  min-height: 400px;
}

.section.hidden { display: none; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 20px;
  flex-wrap: wrap;
}

.search-container {
  display: flex;
  gap: 10px;
  flex: 1;
  max-width: 400px;
}

.search-container .input { flex: 1; }

.input, .textarea {
  width: 100%; 
  padding: 10px 14px; 
  border: 1px solid var(--border);
  border-radius: 8px; 
  background: var(--surface); 
  color: var(--text);
  font-size: 15px; 
  margin-bottom: 12px; 
  transition: border 0.2s;
}

.input:focus, .textarea:focus { 
  outline: none; 
  border-color: var(--accent); 
}

.textarea { 
  resize: vertical; 
  font-family: inherit; 
}

.btn, .btn-outline, .btn-sm, .btn-danger {
  padding: 10px 18px; 
  border: none; 
  border-radius: 8px; 
  cursor: pointer;
  font-size: 15px; 
  font-weight: 600; 
  transition: all 0.2s;
  white-space: nowrap;
}

.btn { 
  background: var(--accent); 
  color: white; 
}

.btn:hover { 
  background: var(--accent2); 
  transform: translateY(-1px); 
}

.btn-outline { 
  background: transparent; 
  border: 1px solid var(--border); 
  color: var(--text); 
}

.btn-outline:hover { background: var(--hover); }

.btn-sm { 
  padding: 6px 12px; 
  font-size: 14px; 
  background: var(--accent);
  color: white;
}

.btn-danger { 
  background: var(--danger); 
  color: white; 
}

.btn-danger:hover { background: #c93d49; }

.novels-grid {
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); 
  gap: 20px; 
  margin-top: 20px;
}

.novel-card {
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: var(--round);
  overflow: hidden; 
  transition: transform 0.2s, box-shadow 0.2s; 
  text-decoration: none; 
  color: var(--text);
  display: block;
}

.novel-card:hover { 
  transform: translateY(-4px); 
  box-shadow: 0 8px 20px rgba(0,0,0,0.12); 
}

.novel-cover { 
  width: 100%; 
  height: 240px; 
  object-fit: cover; 
  display: block;
}

.novel-info { padding: 12px; }

.novel-title { 
  font-size: 16px; 
  font-weight: 700; 
  margin: 0 0 6px; 
}

.novel-author { 
  font-size: 13px; 
  color: var(--text-muted); 
  margin: 0 0 4px; 
}

.novel-genre { 
  font-size: 12px; 
  color: var(--accent); 
  margin: 0; 
}

.bookmarks-grid {
  display: flex; 
  flex-direction: column; 
  gap: 20px; 
  margin-top: 20px;
}

.bookmark-card {
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: var(--round);
  padding: 20px; 
  display: flex; 
  gap: 20px; 
  align-items: flex-start;
}

.admin-card {
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: var(--round);
  padding: 24px; 
  margin-bottom: 24px;
}

.admin-card h3 { margin-top: 0; margin-bottom: 16px; }
.admin-card label { display: block; margin-bottom: 8px; font-weight: 600; }

.tag {
  display: inline-block; 
  padding: 4px 10px; 
  background: var(--hover); 
  color: var(--accent);
  border-radius: 6px; 
  font-size: 13px; 
  margin-right: 6px; 
  margin-bottom: 6px;
}

.chapter-link {
  display: block; 
  padding: 12px 16px; 
  background: var(--surface);
  border: 1px solid var(--border); 
  border-radius: 8px; 
  margin-bottom: 10px;
  color: var(--text); 
  text-decoration: none;
  transition: all 0.2s;
}

.chapter-link:hover {
  background: var(--hover); 
  border-color: var(--accent); 
  color: var(--accent);
}

.footer {
  background: var(--surface); 
  border-top: 1px solid var(--border);
  padding: 24px 0; 
  text-align: center; 
  color: var(--text-muted); 
  margin-top: auto;
}

.hidden { display: none !important; }

/* Hamburger Menu */
.hamburger-menu {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  overflow-y: auto;
}

.hamburger-menu-content {
  background: var(--surface);
  width: 85%;
  max-width: 320px;
  height: 100%;
  margin-left: auto;
  padding: 20px;
  overflow-y: auto;
  box-shadow: -4px 0 10px rgba(0,0,0,0.2);
}

.hamburger-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.hamburger-menu-links {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 30px;
}

.ham-nav-link {
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s;
}

.ham-nav-link:hover, .ham-nav-link.active {
  background: var(--hover);
  color: var(--accent);
}

.hamburger-menu-section {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.hamburger-menu-section:last-child { border-bottom: none; }

.hamburger-menu-section h4 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Responsive */
@media (max-width: 768px) {
  .classic-nav { display: none !important; }
  .hamburger-btn { display: block !important; }
  .logo-main { font-size: 22px; }
  .section-header { flex-direction: column; align-items: stretch; }
  .search-container { max-width: none; }
  .novels-grid { 
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
    gap: 14px; 
  }
  .novel-cover { height: 200px; }
  .bookmark-card { flex-direction: column; }
  .container-wide { padding: 0 15px; }
  .section { padding: 20px 0; }
}

@media (max-width: 480px) {
  .novels-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
  }
  .novel-cover { height: 180px; }
  .novel-info { padding: 8px; }
  .novel-title { font-size: 14px; }
}
/* Chapter content font size fix */
#chapter-content {
  font-size: var(--font-size, 16px) !important;
}

#chapter-content p {
  font-size: inherit;
  margin-bottom: 1.2em;
}

/* Dropdown menu fixes */
.dropdown-menu {
  pointer-events: auto;
}

.dropdown-section select,
.dropdown-section button,
.dropdown-section input {
  pointer-events: auto;
}

/* Chapter content font size fix */
#chapter-content {
  font-size: var(--font-size, 16px) !important;
}

#chapter-content p {
  font-size: inherit;
  margin-bottom: 1.2em;
}

/* Dropdown menu fixes */
.dropdown-menu {
  pointer-events: auto;
}

.dropdown-section select,
.dropdown-section button,
.dropdown-section input {
  pointer-events: auto;
}
