:root {
  --poetry-bg: #f5faf7;
  --poetry-green: #08794d;
  --poetry-green-dark: #075d3e;
  --poetry-green-soft: #edf7f1;
  --poetry-text: #10251b;
  --poetry-muted: #66766d;
  --poetry-line: #d7e4dc;
  --poetry-white: #fff;
}

body {
  background: var(--poetry-bg);
  color: var(--poetry-text);
}

.poetry-page {
  max-width: 1160px;
  padding-top: 26px;
  padding-bottom: 48px;
}

.poetry-breadcrumb {
  margin: 0 0 14px 328px;
  color: var(--poetry-muted);
}

.poetry-breadcrumb a {
  color: inherit;
  text-decoration: none;
}

.poetry-breadcrumb a:hover {
  color: var(--poetry-green);
}

.poetry-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.poetry-directory {
  position: sticky;
  top: 82px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 102px);
  overflow: hidden;
  border: 1px solid var(--poetry-line);
  border-radius: 8px;
  background: var(--poetry-white);
}

.poetry-directory-head {
  padding: 24px 20px 18px;
  border-bottom: 1px solid var(--poetry-line);
}

.poetry-directory-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
}

.poetry-directory-head > p:not(.poetry-stage-note):not(.poetry-directory-title) {
  margin: 6px 0 16px;
  color: var(--poetry-muted);
  font-size: 16px;
}

.poetry-search-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.poetry-search {
  width: 100%;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--poetry-line);
  border-radius: 6px;
  background: #fff;
  color: var(--poetry-text);
  font: inherit;
}

.poetry-search:focus,
.poetry-filter:focus-visible,
.poetry-directory-item:focus-visible,
.poetry-pdf-button:focus-visible,
.poetry-mobile-directory summary:focus-visible {
  outline: 3px solid rgba(8, 121, 77, 0.22);
  outline-offset: 2px;
}

.poetry-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.poetry-filter {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--poetry-line);
  border-radius: 6px;
  background: #fff;
  color: var(--poetry-text);
  font: inherit;
  cursor: pointer;
}

.poetry-filter:hover,
.poetry-filter.is-active {
  border-color: var(--poetry-green);
  background: var(--poetry-green);
  color: #fff;
}

.poetry-stage-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--poetry-green-soft);
  color: var(--poetry-green-dark);
  font-size: 13px;
  line-height: 1.6;
}

.poetry-content-meta {
  margin-top: 18px;
  padding: 18px 22px;
  border: 1px solid var(--poetry-line);
  border-radius: 8px;
  background: var(--poetry-white);
  color: var(--poetry-muted);
  font-size: 14px;
  line-height: 1.7;
}

.poetry-content-meta p {
  margin: 0;
}

.poetry-content-meta p + p {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 6px;
}

.poetry-content-meta a {
  color: var(--poetry-green);
  font-weight: 700;
}

.poetry-directory-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.poetry-directory-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.poetry-directory-row {
  border-bottom: 1px solid #e6eee9;
}

.poetry-directory-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 15px 18px 14px 22px;
  border: 0;
  background: #fff;
  color: var(--poetry-text);
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.poetry-directory-item strong,
.poetry-directory-item span {
  display: block;
}

.poetry-directory-item strong {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.45;
}

.poetry-directory-item span {
  margin-top: 3px;
  color: var(--poetry-muted);
  font-size: 13px;
}

.poetry-directory-item > span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.poetry-directory-status {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: #eef3f0;
  color: #78857e;
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
}

.poetry-directory-item:hover {
  background: #f8fbf9;
}

.poetry-directory-item.is-current {
  background: var(--poetry-green-soft);
}

.poetry-directory-item.is-current::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: #0aa36b;
  content: "";
}

.poetry-empty {
  margin: 0;
  padding: 28px 20px;
  color: var(--poetry-muted);
  text-align: center;
}

.poetry-content {
  min-width: 0;
}

.poem-hero,
.learning-column {
  border: 1px solid var(--poetry-line);
  border-radius: 8px;
  background: var(--poetry-white);
}

.poem-hero {
  position: relative;
  min-height: 330px;
  padding: 34px 38px 36px;
  text-align: center;
}

.poem-genre {
  position: absolute;
  top: 30px;
  left: 28px;
  color: var(--poetry-green);
  font-size: 16px;
  font-weight: 700;
}

.poetry-pdf-button {
  position: absolute;
  top: 28px;
  right: 28px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 6px;
  background: var(--poetry-green);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.poetry-pdf-button:hover {
  background: var(--poetry-green-dark);
}

.poetry-pdf-button[hidden] {
  display: none;
}

.poem-hero h1 {
  margin: 20px 130px 8px;
  font-size: clamp(36px, 4vw, 50px);
  line-height: 1.2;
}

.poem-byline {
  margin: 0;
  color: var(--poetry-muted);
  font-size: 18px;
}

.poem-original {
  margin-top: 38px;
}

.poem-line {
  margin: 0 0 10px;
  font-size: clamp(23px, 2.3vw, 30px);
  line-height: 1.65;
  letter-spacing: 0.05em;
}

.poem-line ruby {
  ruby-align: center;
  ruby-position: over;
}

.poem-line rt {
  display: none;
  color: #5f7469;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.43em;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
}

.poem-original.is-pinyin-visible .poem-line {
  margin-bottom: 18px;
  line-height: 1.65;
}

.poem-original.is-pinyin-visible .poem-line ruby {
  display: inline-flex;
  flex-direction: column-reverse;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  vertical-align: bottom;
}

.poem-original.is-pinyin-visible rt {
  display: block;
}

.pinyin-toggle-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.pinyin-toggle {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid var(--poetry-green);
  border-radius: 6px;
  background: #fff;
  color: var(--poetry-green);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.pinyin-toggle:hover {
  background: var(--poetry-green-soft);
}

.pinyin-toggle:focus-visible {
  outline: 3px solid rgb(10 163 107 / 22%);
  outline-offset: 2px;
}

.pinyin-toggle[aria-pressed="true"] {
  background: var(--poetry-green);
  color: #fff;
}

.learning-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 24px;
  align-items: start;
}

.learning-grid.is-stacked {
  grid-template-columns: 1fr;
}

.learning-column {
  padding: 22px 24px;
}

.learning-section + .learning-section {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--poetry-line);
}

.learning-section h2 {
  margin: 0 0 12px;
  color: var(--poetry-green);
  font-size: 21px;
  line-height: 1.35;
}

.learning-section p,
.annotation-list {
  margin: 0;
  font-size: 16px;
  line-height: 1.9;
}

.annotation-list {
  padding-left: 20px;
}

.annotation-list li + li {
  margin-top: 6px;
}

.line-explanation + .line-explanation {
  margin-top: 17px;
}

.line-explanation strong {
  line-height: 1.7;
}

.line-explanation p {
  margin-top: 6px;
  color: #405248;
}

.poetry-mobile-directory {
  display: none;
}

@media (max-width: 900px) {
  .poetry-page {
    padding-top: 12px;
  }

  .poetry-breadcrumb {
    margin-left: 0;
  }

  .poetry-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .poetry-directory {
    display: none;
  }

  .poetry-mobile-directory {
    display: block;
    margin-bottom: 14px;
    border: 1px solid var(--poetry-line);
    border-radius: 8px;
    background: #fff;
  }

  .poetry-mobile-directory summary {
    display: flex;
    justify-content: space-between;
    padding: 14px 16px;
    color: var(--poetry-green-dark);
    font-weight: 700;
    cursor: pointer;
  }

  .poetry-mobile-directory summary span {
    color: var(--poetry-muted);
    font-weight: 400;
  }

  .poetry-mobile-directory summary strong {
    font-weight: 700;
  }

  .poetry-mobile-directory-body {
    max-height: 62vh;
    overflow: auto;
    border-top: 1px solid var(--poetry-line);
  }

  .poetry-directory-mobile-copy .poetry-directory-scroll {
    max-height: none;
    min-height: 0;
    overflow: visible;
    scrollbar-gutter: auto;
  }

  .poem-hero {
    min-height: 0;
    padding: 70px 18px 28px;
  }

  .poem-genre {
    top: 20px;
    left: 18px;
  }

  .poetry-pdf-button {
    top: 14px;
    right: 14px;
    min-height: 40px;
    padding: 0 14px;
  }

  .poem-hero h1 {
    margin: 10px 0 6px;
    font-size: 36px;
  }

  .poem-original {
    margin-top: 28px;
  }

  .poem-line {
    font-size: 22px;
    line-height: 1.7;
  }

  .learning-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 16px;
  }

  .learning-column {
    padding: 20px 18px;
  }
}

@media (max-width: 560px) {
  .poetry-page {
    padding-right: 14px;
    padding-left: 14px;
  }

  .poetry-breadcrumb {
    overflow-x: auto;
    white-space: nowrap;
  }

  .poem-hero {
    padding-top: 76px;
  }

  .poem-genre {
    font-size: 14px;
  }

  .poem-original {
    margin-top: 22px;
  }

  .poem-line {
    font-size: 20px;
    letter-spacing: 0;
  }
}

@page {
  size: A4;
  margin: 16mm 15mm 18mm;
}

@media print {
  body {
    background: #fff;
    color: #111;
    font-size: 11pt;
  }

  .site-header,
  .poetry-breadcrumb,
  .poetry-directory,
  .poetry-mobile-directory,
  .poetry-pdf-button,
  .screen-only {
    display: none !important;
  }

  .poetry-page,
  .poetry-layout,
  .learning-grid {
    display: block;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .poem-hero,
  .learning-column {
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  .learning-column + .learning-column {
    margin-top: 20px;
  }

  .poem-hero h1,
  .poem-byline,
  .learning-section h2,
  .annotation-list li,
  .line-explanation {
    break-inside: avoid;
  }

  .learning-section h2 {
    break-after: avoid;
  }

  .learning-section p {
    orphans: 3;
    widows: 3;
  }
}
