body {
  margin: 0;
  padding: 0;
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* 🎨 ระบบธีมถนอมสายตา */
.theme-light {
  background-color: #ffffff;
  color: #1a1e21;
}

.theme-sepia {
  background-color: #f4ecd8;
  color: #5b4636;
}

.theme-dark {
  background-color: #121212;
  color: #e0e0e0;
}

.theme-amoled {
  background-color: #000000;
  color: #ffffff;
}

/* 📦 เลย์เอาต์และคอนเทนเนอร์หลัก */
.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 20px 24px 80px 24px;
  box-sizing: border-box;
}

/* 🏠 หน้าหลัก - สารบัญ */
.header {
  text-align: center;
  margin-bottom: 40px;
  padding-top: 30px;
}

.header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 10px;
  background: linear-gradient(45deg, #ff7b00, #ffae00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header p {
  opacity: 0.8;
  font-size: 0.95rem;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.chapter-card {
  padding: 18px 20px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chapter-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.05);
  border-color: #ff9d00;
}

.theme-light .chapter-card {
  background: #ffffff;
  border-color: #eaeaea;
}

.theme-sepia .chapter-card {
  background: #ebe3cf;
  border-color: #decab4;
}

.chapter-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.chapter-meta {
  font-size: 0.85rem;
  opacity: 0.7;
}

/* 📖 หน้ารี๊ดเดอร์อ่านนิยาย */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  margin-bottom: 30px;
  border-bottom: 1px solid rgba(128,128,128,0.15);
}

.btn {
  background: none;
  border: 1px solid rgba(128,128,128,0.3);
  padding: 8px 16px;
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.2s;
  text-decoration: none;
}

.btn:hover {
  background: rgba(128,128,128,0.1);
}

/* ⚙️ แผงควบคุมสไตล์ (Floating Panel) */
.controls-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.style-panel {
  display: none;
  position: absolute;
  top: 65px;
  right: 24px;
  background: #1e1e1e;
  border: 1px solid #333;
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
  z-index: 100;
  flex-direction: column;
  gap: 15px;
  width: 200px;
}

.theme-light .style-panel {
  background: #ffffff;
  border-color: #ddd;
  box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.theme-sepia .style-panel {
  background: #ebe3cf;
  border-color: #decab4;
  box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}

.theme-amoled .style-panel {
  background: #000000;
  border-color: #333;
  box-shadow: 0 10px 20px rgba(255,255,255,0.05);
}

.style-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.style-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  font-weight: 700;
  opacity: 0.7;
}

.theme-buttons {
  display: flex;
  gap: 8px;
}

.theme-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  cursor: pointer;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.theme-btn:hover {
  transform: scale(1.1);
}

.theme-btn.active {
  border: 2.5px solid #ff9d00 !important;
  box-shadow: 0 0 6px rgba(255, 157, 0, 0.5);
}

.font-size-controls {
  display: flex;
  gap: 10px;
}

.font-btn {
  flex: 1;
  background: rgba(128,128,128,0.15);
  border: none;
  padding: 6px 0;
  border-radius: 6px;
  color: inherit;
  cursor: pointer;
  font-weight: 600;
}

/* 📝 ตัวอักษรนิยายแบบลดภาระสายตามือถือ */
.novel-content {
  font-size: 1.15rem;
  line-height: 1.8;
  letter-spacing: 0.3px;
  word-wrap: break-word;
  text-align: justify;
}

.novel-content p {
  margin-bottom: 1.6em;
  text-indent: 1.5em;
}

/* 🚫 สัญลักษณ์การก๊อปปี้บล็อกในเบราว์เซอร์ */
::selection {
  background: transparent;
}
::-moz-selection {
  background: transparent;
}

/* 📚 Story Selector Styles */
.story-selector {
  margin-bottom: 25px;
}

.story-book-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 16px 20px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.2s ease;
}

.story-book-card:hover {
  transform: translateY(-2px);
  border-color: #ff9d00;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.05);
}

.story-book-card.active .expand-arrow {
  transform: rotate(180deg);
  color: #ff9d00;
}

.theme-light .story-book-card {
  background: #ffffff;
  border-color: #eaeaea;
}

.theme-sepia .story-book-card {
  background: #ebe3cf;
  border-color: #decab4;
}

.book-cover {
  font-size: 2rem;
}

.book-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 4px;
}

.book-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.book-author {
  font-size: 0.85rem;
  opacity: 0.65;
}

.expand-arrow {
  font-size: 0.9rem;
  transition: transform 0.2s ease;
  opacity: 0.6;
}

/* 🔍 Search Container Styles */
.search-container {
  margin-bottom: 20px;
}

#chapter-search {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  box-sizing: border-box;
  border: 1px solid rgba(128, 128, 128, 0.3);
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#chapter-search:focus {
  border-color: #ff9d00;
  box-shadow: 0 0 8px rgba(255, 157, 0, 0.25);
}

.theme-light #chapter-search {
  background: #ffffff;
  border-color: #ddd;
}

.theme-sepia #chapter-search {
  background: #fdfaf2;
  border-color: #decab4;
}

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

