* { box-sizing: border-box; }
body { margin: 0; padding: 0; background-color: #fff; color: #000; -webkit-font-smoothing: antialiased; }

.main-layout {
  display: flex;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  gap: 1.5rem;
  max-width: 850px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}
.sidebar { width: 180px; flex: 0 0 180px; border-right: 1px solid #eee; padding-right: 15px; }
.main { flex: 1; min-width: 0; }
h1 { font-size: 1.5rem; color: inherit; margin-bottom: 1.2rem; margin-top: 0; }
h2 { font-size: 1.3rem; margin: 0 0 6px 0; color: inherit; font-weight: bold; }
h2 a { text-decoration: none; color: inherit; }
h2 a:hover { color: #007AFF; }
.m-desc { color: inherit; opacity: 0.8; font-size: 1rem; line-height: 1.5; margin-bottom: 20px; margin-top: 0; }

/* Settings Panel */
#settings-panel {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #f8f9fa;
  padding: 60px 15px 20px 15px;
  z-index: 2000;
  font-family: -apple-system, sans-serif;
  overflow: hidden;
}

.settings-close {
  position: absolute; top: 12px; left: 12px; z-index: 2010; 
  width: 44px; height: 44px; border-radius: 22px; background: white; 
  border: 1px solid #ccc; font-size: 20px; cursor: pointer; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.15); display: flex; 
  align-items: center; justify-content: center; color: #333; 
  outline: none; -webkit-tap-highlight-color: transparent;
}

.settings-title { text-align: center; margin-top: 0; margin-bottom: 15px; font-size: 1.3rem; }
.settings-group { margin-bottom: 15px; max-width: 600px; margin-left: auto; margin-right: auto; }
.settings-label { font-weight: bold; margin-bottom: 8px; font-size: 1rem; color: #555; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.settings-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.settings-flex { display: flex; gap: 8px; }

.btn-setting {
  padding: 10px; font-size: 1.1rem; border: 1px solid #ddd; 
  background: white; border-radius: 6px; text-align: center; 
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn-setting.active {
  border: 2px solid #000;
  font-weight: bold;
}

.btn-setting-size { padding: 12px 0; }
.btn-setting-theme { flex: 1; padding: 12px 0; color: black; }

/* Reader Specific */
.reader-container { 
  display: none; height: 100vh; overflow: hidden; padding: 0; 
  max-width: 800px; margin: 0 auto; background: inherit; 
  position: relative; 
}

.nav-zone-prev { position: fixed; top: 0; left: 0; bottom: 0; width: 35%; z-index: 900; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.nav-zone-next { position: fixed; top: 0; right: 0; bottom: 0; width: 35%; z-index: 900; cursor: pointer; -webkit-tap-highlight-color: transparent; }

.reader-content { 
  padding-top: 0px; padding-bottom: 60px; padding-left: 20px; padding-right: 20px; 
  height: 100vh; overflow: hidden; 
}

.reader-header h1 { font-size: 1.6rem; margin-bottom: 1rem; margin-top: 0; color: inherit; }
.article-body, .article-body * { color: inherit !important; }

.reader-footer { position: fixed; bottom: 12px; left: 0; right: 0; text-align: center; z-index: 1000; }
.btn-reader-back {
  display: inline-block; padding: 6px 16px; background: #f0f0f0; 
  border-radius: 20px; border: 1px solid #ccc; font-size: 0.9rem; 
  color: #444; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
  -webkit-tap-highlight-color: transparent;
}

.page-indicator { font-family: -apple-system, sans-serif; font-size: 0.85rem; color: #666; }

/* Ensure sidebar stays on the left even on narrow screens */
@media (max-width: 480px) {
  .main-layout { gap: 1rem; padding: 10px; }
  .sidebar { width: 140px; flex: 0 0 140px; }
  .sidebar div, .sidebar a { font-size: 1rem !important; }
}
