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

body {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.7;
  color: #1a1a1a;
  background: #f9f9f6;
}

.container {
  min-height: 100vh;
  position: relative;
}

.text-column {
  max-width: 740px;
  margin: 0 auto;
  padding: 2rem 3rem 3rem 3rem;
}

.text-column h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.text-column h3 {
  font-size: 1rem;
  font-weight: normal;
  color: #555;
  margin-bottom: 1rem;
}

.text-column h4 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.75rem;
}

.text-column p {
  margin-bottom: 1rem;
  text-align: justify;
}

.text-column .quote {
  margin-left: 1.5rem;
  border-left: 3px solid #ccc;
  padding-left: 1rem;
  color: #444;
  font-style: italic;
}

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100vh;
  background: #fff;
  border-left: 1px solid #ddd;
  padding: 2rem 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  transform: translateX(0);
  transition: transform 0.3s ease;
  box-shadow: -4px 0 16px rgba(0,0,0,0.12);
}

.sidebar.collapsed {
  transform: translateX(100%);
}

.sidebar-toggle {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  font-size: 1rem;
  line-height: 1;
  z-index: 5;
  color: #555;
}

.sidebar-toggle:hover {
  background: #f0f0f0;
}

.sidebar-content {
  padding-top: 1.5rem;
}

.sidebar-content h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: #333;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.5rem;
}

.sidebar-hint {
  color: #999;
  font-style: italic;
  font-size: 0.9rem;
}

.sidebar-reopen {
  display: none;
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  background: #fff;
  border: 1px solid #ddd;
  border-right: none;
  border-radius: 4px 0 0 4px;
  cursor: pointer;
  padding: 0.75rem 0.4rem;
  font-size: 0.8rem;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  z-index: 100;
  color: #555;
  box-shadow: -1px 0 4px rgba(0, 0, 0, 0.08);
  letter-spacing: 0.1em;
}

.sidebar-reopen:hover {
  background: #f4f4f4;
  color: #222;
}

.sidebar-reopen.visible {
  display: block;
}

.popoutHighlight {
  text-decoration: underline dotted #000000;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.popoutHighlight:hover {
  background-color: #fff3b0;
  text-decoration: none;
}

.popoutHighlight.active {
  background-color: #ffe066;
  text-decoration: none;
}

@keyframes jumpPulse {
  0% { background-color: transparent; }
  20% { background-color: #ffd700; }
  70% { background-color: #ffd700; }
  100% { background-color: transparent; }
}

.popoutHighlight.jump-highlight {
  animation: jumpPulse 1.5s ease-in-out;
}

.glossary-title {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 0.25rem;
  color: #333;
}

.glossary-subtitle {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 1rem;
  font-style: italic;
}

.glossary-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.glossary-item:last-child {
  border-bottom: none;
}

.glossary-term {
  cursor: pointer;
  color: #1a1a1a;
  font-weight: 500;
  flex: 1;
  transition: color 0.15s;
}

.glossary-term:hover {
  color: #b8860b;
}

.glossary-jump {
  cursor: pointer;
  font-size: 0.78rem;
  color: #999;
  white-space: nowrap;
  padding: 0.2rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fff;
  transition: all 0.15s;
  text-decoration: none;
  font-family: inherit;
}

.glossary-jump:hover {
  background: #f0f0f0;
  color: #333;
  border-color: #bbb;
}

.popout {
  display: none;
}

/* --- Site header --- */
.site-header {
  text-align: center;
  padding: 3rem 0 0.5rem;
  border-bottom: 2px solid #ddd;
  margin-bottom: 2.5rem;
}

.site-header h1 {
  font-size: 2.2rem;
  font-weight: normal;
  letter-spacing: 0.05em;
  color: #1a1a1a;
  margin-bottom: 0.4rem;
}

.site-header h1 a {
  color: inherit;
  text-decoration: none;
}

.site-header h1 a:hover {
  color: #b8860b;
}

.library-back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: #888;
  text-decoration: none;
  margin-bottom: 2rem;
  transition: color 0.15s;
}

.library-back-link:hover {
  color: #b8860b;
}

/* --- Cover page --- */
.cover-page {
  padding-top: 1rem;
  padding-bottom: 4rem;
}

.cover-layout {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}

.cover-image-wrapper {
  flex-shrink: 0;
  width: 280px;
}

.cover-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 3px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.cover-info {
  flex: 1;
  min-width: 0;
}

.cover-author {
  font-size: 1rem;
  color: #888;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.cover-title {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 0.3rem;
  line-height: 1.2;
}

.cover-subtitle {
  font-size: 1rem;
  color: #666;
  font-style: italic;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.cover-year {
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 1.5rem;
}

.cover-description p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #333;
  text-align: justify;
  margin-bottom: 1.5rem;
}

.cover-chapters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.cover-chapters .chapter-link,
.cover-chapters .placeholder {
  flex: 0 0 calc(33.333% - 0.35rem);
  text-align: center;
  padding: 0.5rem 0.4rem;
  box-sizing: border-box;
}

.cover-back-link {
  color: inherit;
  text-decoration: none;
}

.cover-back-link:hover {
  color: #b8860b;
}

.back-to-cover {
  display: inline-block;
  font-size: 0.85rem;
  color: #888;
  text-decoration: none;
  margin-bottom: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 3px;
  padding: 0.2rem 0.7rem;
  transition: all 0.15s;
}

.back-to-cover:hover {
  background: #f0ede6;
  border-color: #b8860b;
  color: #1a1a1a;
}

.chapter-link {
  font-size: 0.85rem;
  padding: 0.2rem 0.7rem;
  border: 1px solid #ddd;
  border-radius: 3px;
  color: #555;
  text-decoration: none;
  transition: all 0.15s;
}

.chapter-link:hover {
  background: #f0ede6;
  border-color: #b8860b;
  color: #1a1a1a;
}

.placeholder {
  font-size: 0.85rem;
  color: #bbb;
  font-style: italic;
}

/* --- Audio Player --- */
.audio-player {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.audio-player.visible {
  opacity: 1;
  pointer-events: auto;
}
.audio-player-controls {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #ddd;
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 0 16px;
  opacity: 0;
  transition: max-height 0.35s ease, padding 0.35s ease, opacity 0.35s ease;
}
.audio-player.expanded .audio-player-controls {
  max-height: 60px;
  padding: 8px 16px;
  opacity: 1;
}
.audio-expand-btn {
  display: none;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  font-size: 18px;
  padding: 2px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.audio-player.playing .audio-expand-btn {
  display: flex;
}
.audio-expand-btn:hover {
  color: #333;
}
.speed-btn {
  background: none;
  border: 2px solid #ccc;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 16px;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s;
}
.speed-btn:hover {
  border-color: #b8860b;
  color: #b8860b;
}
.speed-display {
  font-size: 14px;
  font-weight: 600;
  color: #666;
  min-width: 42px;
  text-align: center;
  font-family: monospace;
}
.audio-player-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 28px;
  padding: 0;
  overflow: hidden;
  flex-shrink: 0;
  min-width: 46px;
  transition: min-width 0.4s ease, gap 0.4s ease, padding 0.4s ease;
}
.audio-player.playing .audio-player-inner {
  min-width: 180px;
  gap: 6px;
  padding: 4px;
}
.audio-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(184, 134, 11, 0.25);
  border-radius: 28px;
  width: 0%;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.audio-player.playing .audio-progress {
  opacity: 1;
}
.play-btn {
  position: relative;
  z-index: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #b8860b;
  color: #fff;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
  transition: background 0.15s;
}
.play-btn:hover {
  background: #a07509;
}
.play-btn .material-icons-outlined {
  font-size: 24px;
}

/* --- Current Line Highlight --- */
.current-line {
  background: rgba(184, 134, 11, 0.15);
  border-radius: 2px;
  transition: background 0.3s;
}
.sentence-segment {
  transition: background 0.3s;
}

@media (max-width: 700px) {
  .cover-layout {
    flex-direction: column;
    align-items: center;
  }

  .cover-image-wrapper {
    width: 200px;
  }

  .cover-info {
    text-align: center;
  }

  .cover-chapters {
    justify-content: center;
  }

  .audio-player {
    bottom: 16px;
    right: 16px;
  }
  .audio-player-inner {
    padding: 0;
    min-width: 40px;
  }
  .audio-player.playing .audio-player-inner {
    gap: 4px;
    min-width: 140px;
    padding: 2px;
  }
  .audio-player-controls {
    padding: 0 12px;
  }
  .audio-player.expanded .audio-player-controls {
    padding: 6px 12px;
  }
  .play-btn {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }
  .play-btn .material-icons-outlined {
    font-size: 20px;
  }
  .audio-expand-btn {
    font-size: 16px;
  }
  .speed-btn {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }
  .speed-display {
    font-size: 12px;
    min-width: 34px;
  }
}
