/* Page layout */
.page {
  min-height: 100vh;
  background: #0d1117;
  color: #c9d1d9;
}

.header {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 2rem 1rem;
  border-bottom: 1px solid #21262d;
  text-align: center;
}

.pageTitle {
  font-size: 2.5rem;
  font-weight: 300;
  color: #f0f6fc;
  margin: 0 0 0.5rem;
  letter-spacing: 0.1em;
}

.subtitle {
  color: #8b949e;
  font-size: 1rem;
  margin: 0;
}

/* Table of Contents */
.toc {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 1.5rem 2rem;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
}

.tocTitle {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: #f0f6fc;
}

.tocList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.tocSection {
  margin: 0;
}

.tocSection strong {
  color: #58a6ff;
  display: block;
  margin-bottom: 0.5rem;
}

.tocWorks {
  list-style: none;
  padding: 0 0 0 1rem;
  margin: 0;
}

.tocWorks li {
  margin: 0.25rem 0;
  font-size: 0.9rem;
}

.tocWorks a {
  color: #c9d1d9;
  text-decoration: none;
}

.tocWorks a:hover {
  color: #58a6ff;
  text-decoration: underline;
}

.tocFileCount {
  color: #6e7681;
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

/* Main content */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* Section (author/category) */
.section {
  margin-bottom: 4rem;
}

.sectionTitle {
  font-size: 1.75rem;
  font-weight: 600;
  color: #f0f6fc;
  margin: 0 0 2rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #58a6ff;
}

.worksContainer {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

/* Individual work */
.work {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  overflow: hidden;
}

.workHeader {
  padding: 1.5rem;
  border-bottom: 1px solid #21262d;
  background: linear-gradient(180deg, #1c2128 0%, #161b22 100%);
}

.workTitle {
  font-size: 1.5rem;
  font-weight: 600;
  color: #f0f6fc;
  margin: 0 0 0.25rem;
}

.workAuthor {
  color: #8b949e;
  margin: 0;
  font-size: 1rem;
}

.authorDates {
  color: #6e7681;
}

.sourceNote {
  color: #6e7681;
  font-style: italic;
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

.language,
.translation {
  color: #6e7681;
  font-size: 0.85rem;
  margin: 0.25rem 0 0;
}

/* Image strip */
.imageStrip {
  display: flex;
  overflow-x: auto;
  gap: 2px;
  padding: 1rem;
  background: #0d1117;
  border-bottom: 1px solid #21262d;
}

.imageStrip::-webkit-scrollbar {
  height: 8px;
}

.imageStrip::-webkit-scrollbar-track {
  background: #21262d;
}

.imageStrip::-webkit-scrollbar-thumb {
  background: #484f58;
  border-radius: 4px;
}

.imageThumb {
  flex-shrink: 0;
  position: relative;
}

.imageThumb img {
  height: 80px;
  width: auto;
  display: block;
  border-radius: 4px;
  border: 1px solid #30363d;
  transition: transform 0.2s, border-color 0.2s;
}

.imageThumb:hover img {
  transform: scale(1.05);
  border-color: #58a6ff;
}

.imageNumber {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 4px;
  border-radius: 2px;
}

/* Text content */
.textContent {
  padding: 1.5rem;
}

.preformattedText {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 1rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #c9d1d9;
  margin: 0;
  max-height: 600px;
  overflow-y: auto;
}

.preformattedText::-webkit-scrollbar {
  width: 8px;
}

.preformattedText::-webkit-scrollbar-track {
  background: #21262d;
}

.preformattedText::-webkit-scrollbar-thumb {
  background: #484f58;
  border-radius: 4px;
}

/* Expandable segments */
.segments {
  border-top: 1px solid #21262d;
}

.segmentsSummary {
  padding: 1rem 1.5rem;
  cursor: pointer;
  color: #58a6ff;
  font-size: 0.9rem;
  background: #0d1117;
  user-select: none;
}

.segmentsSummary:hover {
  background: #161b22;
}

.segmentsList {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: #21262d;
}

.segment {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: #161b22;
}

.segmentImage {
  flex-shrink: 0;
}

.segmentImage img {
  height: 100px;
  width: auto;
  display: block;
  border-radius: 4px;
  border: 1px solid #30363d;
}

.segmentText {
  min-width: 0;
}

.segmentNumber {
  display: inline-block;
  color: #6e7681;
  font-size: 0.75rem;
  margin-bottom: 0.5rem;
  background: #21262d;
  padding: 2px 6px;
  border-radius: 3px;
}

.segmentText pre {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #c9d1d9;
  margin: 0;
}

/* Footer */
.footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  border-top: 1px solid #21262d;
  text-align: center;
  color: #6e7681;
  font-size: 0.9rem;
}

.footer p {
  margin: 0.25rem 0;
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    padding: 1.5rem 1rem;
  }

  .pageTitle {
    font-size: 1.75rem;
  }

  .toc {
    margin: 1rem;
    padding: 1rem;
  }

  .tocList {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 1rem;
  }

  .workHeader {
    padding: 1rem;
  }

  .workTitle {
    font-size: 1.25rem;
  }

  .imageStrip {
    padding: 0.75rem;
  }

  .imageThumb img {
    height: 60px;
  }

  .textContent {
    padding: 1rem;
  }

  .preformattedText {
    font-size: 0.9rem;
    max-height: 400px;
  }

  .segment {
    grid-template-columns: 80px 1fr;
    padding: 0.75rem 1rem;
  }

  .segmentImage img {
    height: 60px;
  }
}
