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

body {
  font-family: "Georgia", "Times New Roman", serif;
  background-color: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 60px 24px;
  max-width: 800px;
  margin: 0 auto;
}

.header {
  text-align: center;
  margin-bottom: 40px;
}

.header h1 {
  font-size: 3rem;
  font-weight: 300;
  letter-spacing: 2px;
  color: #ffffff;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 1.1rem;
  color: #a0a0b0;
  font-style: italic;
  letter-spacing: 1px;
}

.welcome-text {
  max-width: 560px;
  text-align: center;
  margin-bottom: 60px;
}

.welcome-text p {
  font-size: 1.1rem;
  line-height: 1.8;
  color: #c0c0d0;
}

.works-section {
  width: 100%;
  max-width: 560px;
}

.works-section h2 {
  font-size: 1.4rem;
  font-weight: 400;
  color: #ffffff;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid #333355;
  letter-spacing: 1px;
}

.works-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.work-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: #16213e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  text-decoration: none;
  color: #e0e0e0;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.2s;
}

.work-card:hover {
  background: #1f2f50;
  border-color: #4a4a7a;
  transform: translateY(-2px);
}

.work-icon {
  font-size: 1.8rem;
}

.work-title {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 400;
}

.work-format {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #808090;
  background: #2a2a4a;
  padding: 4px 10px;
  border-radius: 4px;
}

.footer {
  margin-top: 80px;
  text-align: center;
}

.footer p {
  font-size: 0.85rem;
  color: #606070;
}

@media screen and (max-width: 600px) {
  .header h1 {
    font-size: 2rem;
  }

  .container {
    padding: 40px 16px;
  }

  .work-card {
    padding: 16px;
  }
}

/* Reader layout */
.reader {
  /* Theme tokens — dark (default) */
  --bg: #1a1a2e;
  --bg-surface: #16213e;
  --bg-raised: #2a2a4a;
  --bg-hover: #3a3a5a;
  --bg-hover-subtle: #1f2f50;
  --border: #2a2a4a;
  --border-btn: #3a3a5a;
  --border-active: #5a5a7a;
  --text-primary: #ffffff;
  --text-body: #e0e0e0;
  --text-content: #d8d8e8;
  --text-muted: #a0a0b0;
  --text-dimmer: #808090;
  --shadow: rgba(0, 0, 0, 0.4);
  --drawer-bg: #16213e;
  --drawer-hover: #1f2f50;
  --drawer-active: #2a2a4a;
  --drawer-num: #606070;

  /* Reader settings defaults */
  --reader-font-size: 18px;
  --reader-line-height: 2;
  --reader-side-padding: 24px;

  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text-body);
  transition:
    background-color 0.3s,
    color 0.3s;
}

.reader.light-mode {
  --bg: #f5f0e8;
  --bg-surface: #ede8df;
  --bg-raised: #d8d0c4;
  --bg-hover: #c8c0b4;
  --bg-hover-subtle: #e0d8cc;
  --border: #d0c8b8;
  --border-btn: #c0b8a8;
  --border-active: #c0b8a8;
  --text-primary: #111111;
  --text-body: #333333;
  --text-content: #2a2a2a;
  --text-muted: #666666;
  --text-dimmer: #666666;
  --shadow: rgba(0, 0, 0, 0.15);
  --drawer-bg: #f0ebe3;
  --drawer-hover: #e0d8cc;
  --drawer-active: #d8d0c4;
  --drawer-num: #aaaaaa;
}

.reader-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  transition:
    background 0.3s,
    border-color 0.3s;
}

.reader-settings {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.settings-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 100;
  background: var(--bg-surface);
  border: 1px solid var(--border-btn);
  border-radius: 8px;
  padding: 16px;
  min-width: 220px;
  box-shadow: 0 8px 24px var(--shadow);
  flex-direction: column;
  gap: 12px;
}

.settings-panel.open {
  display: flex;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-row-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.settings-row-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-value {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 28px;
  text-align: center;
}

.settings-btn {
  background: var(--bg-raised);
  color: var(--text-body);
  border: 1px solid var(--border-btn);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
  white-space: nowrap;
}

.settings-btn:hover {
  background: var(--bg-hover);
}

.back-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 4px;
  transition:
    background 0.2s,
    color 0.2s;
}

.back-btn:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
}

.book-title {
  flex: 1;
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 400;
}

.reader-body {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 48px 16px 80px;
}

.chapter-content {
  max-width: 680px;
  width: 100%;
  padding: 0 var(--reader-side-padding);
}

.chapter-content p {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-content);
  margin-bottom: calc(var(--reader-line-height) * 0.5em);
  transition: color 0.3s;
}

.chapter-content p:first-child {
  font-size: 1.3rem;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 1.5em;
  transition: color 0.3s;
}

.chapter-content .loading,
.chapter-content .error {
  text-align: center;
  color: var(--text-dimmer);
  font-style: italic;
}

.chapter-controls {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

.chapter-btn {
  background: var(--bg-raised);
  color: var(--text-body);
  border: 1px solid var(--border-btn);
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition:
    background 0.2s,
    border-color 0.2s;
}

.chapter-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-active);
}

.chapter-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.chapter-label {
  font-size: 0.85rem;
  color: var(--text-dimmer);
}

/* Chapters drawer */
.chapters-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
}

.chapters-overlay.open {
  display: block;
}

.chapters-drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: var(--drawer-bg);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px var(--shadow);
}

.chapters-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
}

.chapters-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  transition: color 0.2s;
}

.chapters-close-btn:hover {
  color: var(--text-primary);
}

.chapters-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.chapters-list li {
  padding: 12px 20px;
  font-size: 0.9rem;
  color: var(--text-content);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chapters-list li:hover {
  background: var(--drawer-hover);
  color: var(--text-primary);
}

.chapters-list li.active {
  color: var(--text-primary);
  font-weight: 500;
  background: var(--drawer-active);
}

.chapters-list li .chap-num {
  font-size: 0.75rem;
  color: var(--drawer-num);
  min-width: 24px;
}

.chapters-list li.active .chap-num {
  color: var(--text-muted);
}

@media screen and (max-width: 600px) {
  .reader-nav {
    padding: 12px 16px;
  }

  .reader-body {
    padding: 32px 16px 60px;
  }

  .chapter-controls {
    padding: 12px 16px;
  }

  .chapter-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .book-title {
    display: none;
  }

  .settings-panel {
    position: fixed;
    top: 57px;
    left: 16px;
    right: 16px;
    width: auto;
    min-width: 0;
  }
}
