:root {
  --paper: #f5f0e6;
  --paper-deep: #e9dfcf;
  --ink: #26221e;
  --ink-soft: #655d53;
  --red: #a8402f;
  --red-dark: #7d2c1f;
  --line: rgba(38, 34, 30, 0.14);
  --page: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 8%, rgba(168, 64, 47, 0.05), transparent 25rem),
    linear-gradient(rgba(83, 68, 51, 0.012) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 100% 5px, auto;
  font-family: "Noto Serif SC", "Songti SC", serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
::selection { background: #e5c5b8; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 240, 230, 0.94);
  backdrop-filter: blur(10px);
}

.header-inner {
  width: min(calc(100% - 48px), var(--page));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 32px;
}

.brand { display: flex; align-items: center; gap: 13px; flex: 0 0 auto; }
.seal {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 3px;
  color: var(--paper);
  background: var(--red);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.05;
  object-fit: cover;
  object-position: 43% center;
}
.brand-name { font-size: 19px; font-weight: 600; letter-spacing: 0.3em; }

.primary-nav { display: flex; gap: 30px; align-items: center; }
/* Account actions share the header but stay separate from content navigation. */
.header-account { position: relative; flex: 0 0 auto; }
.account-trigger { display: inline-flex; align-items: center; justify-content: center; min-width: 64px; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; transition: border-color .18s, background .18s; }
.account-trigger:hover { border-color: var(--ink-soft); background: var(--paper); }
.account-trigger.is-signed-in { min-width: 44px; padding: 6px; border-color: transparent; border-radius: 50%; }
.account-trigger img, .account-initial { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.account-initial { display: grid; place-items: center; background: var(--red); color: var(--paper); font-size: 15px; }
.header-account [hidden], #account-dialog [hidden], #account-toast[hidden] { display: none; }
.account-menu { position: absolute; top: calc(100% + 12px); right: 0; width: 216px; padding: 16px 0 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 12px 32px rgba(39, 30, 21, .12); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; }
.account-menu-label { margin: 3px 20px 12px; color: var(--ink-soft); font-size: 12px; }
.account-name { margin: 0 20px; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.account-menu a, .account-menu button { display: block; width: 100%; padding: 12px 20px; min-height: 44px; color: var(--ink); text-align: left; border: 0; background: transparent; font: inherit; font-size: 14px; cursor: pointer; }
.account-menu a:hover, .account-menu button:hover { background: rgba(168, 64, 47, .05); }
.account-menu a span { display: block; margin-top: 3px; font-size: 12px; color: var(--ink-soft); }
#wechat-logout { border-top: 1px solid var(--line); margin-top: 8px; }
#account-menu-feedback { margin: 8px 20px; font-size: 13px; color: var(--red); }
#account-menu-feedback:empty { display: none; }
#account-dialog { position: fixed; width: min(360px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 32px 24px 24px; color: var(--ink); text-align: center; background: #fff; border: 0; border-radius: 12px; box-shadow: 0 20px 64px rgba(39, 30, 21, .16); overflow: auto; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
#account-dialog::backdrop { background: rgba(35, 29, 21, .38); }
#account-close { position: absolute; right: 6px; top: 6px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink-soft); cursor: pointer; }
#account-close:hover { background: rgba(168, 64, 47, .05); color: var(--ink); }
#account-title { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.4; letter-spacing: 0; }
#account-description { margin: 8px 0 18px; color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
.wechat-qr-panel { position: relative; width: 280px; max-width: 100%; height: 190px; margin: 0 auto; overflow: hidden; background: #fff; }
#wechat-qr iframe { display: block; position: relative; left: 50%; transform: translateX(-50%); width: 280px; height: 190px; border: 0; background: #fff; }
.wechat-qr-cover { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(255, 255, 255, .97); font-size: 13px; color: var(--ink-soft); }
#account-feedback { margin: 8px 0 0; color: var(--red); font-size: 13px; line-height: 1.6; }
#account-feedback:empty { display: none; }
.qr-refresh { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px; margin-top: 0; border: 0; background: transparent; color: var(--ink-soft); font: inherit; font-size: 13px; cursor: pointer; }
.qr-refresh:hover { color: var(--red); }
.qr-refresh:disabled { opacity: .5; cursor: wait; }
.account-note { color: var(--ink-soft); font-size: 12px; line-height: 1.6; margin: 4px 0 0; padding: 0; }
.account-toast { position: fixed; z-index: 50; bottom: 28px; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 12px 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); box-shadow: 0 8px 32px rgba(39, 30, 21, .14); font-size: 14px; }
@media (max-width: 620px) {
  .header-account { margin-left: auto; order: 2; }
  .header-inner .primary-nav { margin-left: 0; }
  .header-search { order: 3; }
  .account-trigger { min-width: 56px; padding: 0 10px; }
  #account-dialog { padding: 30px 16px 22px; }
}
.primary-nav a, .primary-nav button {
  padding: 7px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  letter-spacing: 0.18em;
}
.primary-nav .active { color: var(--red); border-bottom-color: var(--red); }

.header-search {
  width: clamp(240px, 28vw, 320px);
  min-width: 0;
  flex: 0 1 320px;
  margin-left: auto;
  display: flex;
  align-items: center;
  padding: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 253, 248, 0.65);
  color: var(--ink-soft);
}
.header-search:focus-within { border-color: var(--ink-soft); }
.header-search input:focus-visible { outline: none; }
.header-search input {
  width: 100%;
  min-width: 0;
  flex: 1;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.header-search input::placeholder { color: var(--ink-soft); }
.header-search-submit {
  min-width: 56px;
  min-height: 44px;
  flex: none;
  padding: 8px 12px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0 4px 4px 0;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}
.header-search-submit:hover { color: var(--red); background: rgba(168, 64, 47, 0.05); }
.header-search-submit:focus-visible { outline: none; background: var(--ink); color: var(--paper); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
main { min-height: calc(100vh - 180px); }
/* Route changes focus this container for assistive technology, not as a control. */
#app:focus { outline: none; }
.page-shell { width: min(calc(100% - 48px), var(--page)); margin: 0 auto; }

.loading-screen {
  min-height: 62vh;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--ink-soft);
  letter-spacing: 0.25em;
}
.loading-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--red);
  color: var(--red);
  font-size: 22px;
  animation: breathe 1.8s ease-in-out infinite;
}
.loading-mark { overflow: hidden; border: 0; border-radius: 4px; }
.loading-mark img { width: 100%; height: 100%; object-fit: cover; object-position: 43% center; }
@keyframes breathe { 50% { opacity: 0.45; transform: scale(0.96); } }

.daily-section { padding: 80px 0 96px; }
.daily-poem { max-width: 760px; margin: 0 auto; text-align: center; }
.eyebrow {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.22em;
}
.eyebrow strong {
  padding: 4px 9px;
  border: 1px solid var(--red);
  color: var(--red);
  font-weight: 500;
}
.daily-poem h1, .poem-title {
  margin: 34px 0 14px;
  font-size: clamp(2.6rem, 6vw, 4rem);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-wrap: balance;
}
.poem-byline { color: var(--ink-soft); font-size: 15px; letter-spacing: 0.25em; }
.poem-lines {
  margin: 48px auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: clamp(1.18rem, 2.5vw, 1.72rem);
  line-height: 1.9;
  letter-spacing: 0.1em;
}
.poem-lines p { margin: 0; text-wrap: pretty; }

.button-row { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.ink-button, .line-button {
  min-height: 46px;
  padding: 11px 26px;
  border: 1px solid var(--ink);
  cursor: pointer;
  font-size: 15px;
  letter-spacing: 0.2em;
}
.ink-button { color: var(--paper); background: var(--ink); }
.ink-button:hover { border-color: var(--red); background: var(--red); }
.line-button { color: var(--ink); background: transparent; }
.line-button:hover, .line-button.saved { color: var(--red); border-color: var(--red); }
.line-button.saved { background: rgba(168, 64, 47, 0.06); }

.section-rule {
  margin-top: 112px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.section-rule h2 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: 0.28em; }
.section-rule a, .section-rule button {
  border: 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 14px;
  letter-spacing: 0.14em;
}
.section-rule a:hover, .section-rule button:hover { color: var(--red); }

.discovery-section { padding: 48px 0 88px; border-top: 1px solid var(--line); }
.discovery-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.section-kicker { color: var(--red); font-size: 12px; letter-spacing: 0.24em; }
.discovery-heading h2 { margin: 10px 0; font-size: 28px; font-weight: 600; letter-spacing: 0.18em; }
.discovery-heading p { margin: 0; font-size: 14px; color: var(--ink-soft); line-height: 1.8; }
.discovery-link { min-height: 44px; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 6px; flex-shrink: 0; font-size: 15px; }
.discovery-link small { color: var(--ink-soft); font-size: 12px; letter-spacing: 0.06em; }
.discovery-link:hover { color: var(--red); }
.poem-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 36px; }
.poem-card {
  display: flex;
  flex-direction: column;
  min-height: 280px;
  min-width: 0;
  padding: 30px 2px 22px;
  background: transparent;
  border-top: 1px solid var(--line);
  border-radius: 0;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: border-color 180ms ease;
}
.poem-card:hover, .poem-card:focus-visible { border-top-color: var(--red); }
.poem-card:hover h3, .poem-card:focus-visible h3 { color: var(--red); }
.poem-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.poem-card-number { color: var(--ink-soft); opacity: 0.35; font-size: 12px; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.poem-card-meta { color: var(--ink-soft); font-size: 13px; letter-spacing: 0.16em; }
.poem-card h3 { margin: 20px 0 18px; font-size: 22px; font-weight: 600; letter-spacing: 0.08em; line-height: 1.6; transition: color 180ms ease; }
.poem-card p { margin: 0; color: var(--ink-soft); font-size: 16px; line-height: 2; letter-spacing: 0.06em; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.poem-card-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-top: 24px; margin-top: auto; color: var(--ink-soft); font-size: 12px; line-height: 1.7; }
.poem-card-foot > span:first-child { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.poem-card-read { color: var(--red); flex-shrink: 0; }

.browse-page, .favorites-page { max-width: 1000px; padding: 64px 0 110px; }
.page-heading { margin: 0; font-size: clamp(2.1rem, 5vw, 3rem); font-weight: 600; letter-spacing: 0.25em; }
.page-kicker { margin: 13px 0 0; color: var(--ink-soft); font-size: 14px; letter-spacing: 0.11em; line-height: 1.8; }
.large-search {
  margin-top: 38px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--ink);
}
.large-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: clamp(1.15rem, 3vw, 1.45rem);
  letter-spacing: 0.06em;
}
.large-search:focus-within { border-bottom-color: var(--red); }
.large-search input:focus-visible { outline: none; }
.large-search button:focus-visible { outline: none; text-decoration: underline; text-underline-offset: 6px; color: var(--red); }
.large-search button {
  min-width: 64px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font-size: 14px;
  letter-spacing: 0.15em;
}
.filter-row { margin-top: 26px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.filter-label { width: 56px; color: var(--ink-soft); font-size: 13px; letter-spacing: 0.25em; }
.filter-chip {
  padding: 7px 15px;
  border: 1px solid rgba(38, 34, 30, 0.22);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
}
.filter-chip.active { border-color: var(--ink); color: var(--paper); background: var(--ink); }

.result-summary { margin: 40px 0 8px; color: var(--ink-soft); font-size: 13px; letter-spacing: 0.11em; }
.result-list { border-top: 1px solid var(--line); }
.result-item {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) auto;
  gap: 30px;
  align-items: baseline;
  padding: 27px 8px;
  border-bottom: 1px solid rgba(38, 34, 30, 0.1);
  cursor: pointer;
}
.result-item:hover { background: rgba(168, 64, 47, 0.035); }
.result-item h2 { margin: 0 0 7px; font-size: 21px; font-weight: 600; letter-spacing: 0.11em; }
.result-author { color: var(--ink-soft); font-size: 13px; letter-spacing: 0.13em; }
.result-excerpt { margin: 0; color: #4b443d; font-size: 16px; line-height: 1.85; letter-spacing: 0.04em; }
.result-source { color: var(--ink-soft); font-size: 12px; text-align: right; }
.pager { margin-top: 38px; display: flex; justify-content: center; gap: 12px; }
.pager button { min-width: 98px; padding: 10px 16px; border: 1px solid var(--line); background: transparent; cursor: pointer; }
.pager button:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.pager button:disabled { opacity: 0.35; cursor: not-allowed; }

.detail-page { max-width: 920px; padding: 62px 0 120px; }
.detail-back { border: 0; background: none; color: var(--ink-soft); cursor: pointer; font-size: 14px; letter-spacing: 0.15em; }
.detail-back:hover { color: var(--red); }
.poem-article { max-width: 720px; margin: 36px auto 0; text-align: center; }
.detail-meta { color: var(--ink-soft); font-size: 13px; letter-spacing: 0.25em; }
.detail-lines { margin-top: 52px; font-size: clamp(1.18rem, 2.6vw, 1.72rem); line-height: 2; letter-spacing: 0.1em; }
.detail-lines p { margin: 0 0 8px; text-wrap: pretty; }
.detail-actions { margin-top: 44px; }
.annotated-line { margin-bottom: 8px; }
.word-note { display: inline; position: relative; }
.word-note-trigger { display: inline; appearance: none; padding: 0; margin: 0; border: 0; border-radius: 0; background: none; color: inherit; font: inherit; line-height: inherit; letter-spacing: inherit; vertical-align: baseline; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(168,64,47,.45); text-underline-offset: .2em; text-decoration-thickness: 1px; }
.word-note-trigger:focus-visible { outline: 2px solid var(--red); outline-offset: 4px; }
.word-note-body { position: absolute; z-index: 12; top: 2.3rem; left: 50%; transform: translateX(-50%); width: 260px; padding: 18px 20px; border: 1px solid #c6b9a7; background: #faf7f0; box-shadow: 0 8px 26px rgba(38,34,30,.12); font-size: 15px; line-height: 1.85; letter-spacing: normal; text-align: left; }
.word-note-body[hidden] { display: none; }
.word-note-body > span { display: block; }
.word-note-body strong { color: var(--red); }
.word-note-body .note-pronunciation { display: inline; margin-left: 10px; font-size: 13px; color: var(--ink-soft); }
.annotation-hint { font-size: 13px; color: var(--ink-soft); margin-top: 20px; }
@media (max-width: 620px) { .word-note.is-open { position: static; } .detail-lines { position: relative; } .word-note-body { top: auto; left: 50%; width: min(290px, calc(100vw - 48px)); } }
.reading-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 22px; margin: 54px 0 28px; padding: 20px 0; border-block: 1px solid var(--line); font-size: 15px; color: var(--red); }
.reading-section { margin-top: 64px; text-align: left; scroll-margin-top: 100px; }
.reading-section h2 { display: flex; align-items: center; gap: 18px; margin: 0 0 30px; color: var(--red); font-size: 18px; font-weight: 600; letter-spacing: .25em; }
.reading-section h2::after { content: ''; height: 1px; background: var(--line); flex: 1; }
.reading-section p { font-size: 18px; line-height: 1.95; margin: 0 0 22px; }
.translation-pair { margin-bottom: 28px; }
.translation-pair .original-line { color: var(--ink-soft); font-size: 16px; margin-bottom: 7px; }
.reading-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 24px 34px; }
.reading-notes dt { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.reading-notes dt span { margin-left: 10px; font-size: 14px; font-weight: 400; color: var(--ink-soft); }
.reading-notes dd { margin: 0; font-size: 16px; line-height: 1.9; }
.reading-prompt { padding: 32px 18px; background: rgba(233, 223, 207, .4); }
.reading-prompt .loading-mark { margin: auto; }
.reading-prompt p { font-size: 16px; line-height: 1.9; }
.reading-disclosure { color: var(--ink-soft); font-size: 13px !important; line-height: 1.8; }
@media (max-width: 620px) { .reading-notes { grid-template-columns: 1fr; } .reading-section p { font-size: 17px; } .reading-nav { gap: 16px; font-size: 14px; } }
.source-panel {
  margin-top: 92px;
  padding: 29px 32px;
  border: 1px solid var(--line);
  background: rgba(233, 223, 207, 0.62);
  text-align: left;
}
.source-panel h2 { margin: 0 0 20px; color: var(--red); font-size: 15px; font-weight: 600; letter-spacing: 0.42em; }
.source-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.source-grid div { display: flex; flex-direction: column; gap: 7px; }
.source-grid span { color: var(--ink-soft); font-size: 12px; letter-spacing: 0.15em; }
.source-grid strong { font-size: 16px; font-weight: 500; line-height: 1.7; }
.neighbor-row { margin-top: 40px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.neighbor-row button {
  min-height: 86px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.neighbor-row button:last-child { text-align: right; }
.neighbor-row button:hover { border-color: var(--red); }
.neighbor-row span { display: block; margin-bottom: 7px; color: var(--ink-soft); font-size: 12px; letter-spacing: 0.2em; }
.neighbor-row strong { font-size: 18px; font-weight: 500; letter-spacing: 0.1em; }

.empty-state { padding: 80px 20px; text-align: center; color: var(--ink-soft); }
.empty-state > span { display: inline-grid; width: 48px; height: 48px; place-items: center; border: 1px solid var(--line); }
.empty-state h2 { margin: 18px 0 8px; color: var(--ink); font-size: 20px; font-weight: 500; letter-spacing: 0.15em; }
.empty-state p { margin: 0; font-size: 14px; }
.error-box { max-width: 560px; margin: 80px auto; padding: 28px; border: 1px solid rgba(168, 64, 47, 0.35); text-align: center; }
.error-box h2 { font-size: 20px; letter-spacing: 0.12em; }
.error-box p { color: var(--ink-soft); line-height: 1.8; }

.site-footer {
  padding: 36px 0;
  border-top: 1px solid var(--line);
  background: rgba(233, 223, 207, 0.32);
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.13em;
  line-height: 1.8;
}
.site-footer p { margin: 3px 0; }
.footer-inner { width: min(calc(100% - 48px), var(--page)); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.footer-identity { display: flex; align-items: center; gap: 24px; }
.footer-brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); font-size: 21px; letter-spacing: 0.16em; }
.footer-brand img { border-radius: 3px; }
.footer-nav { display: flex; gap: 28px; }
.footer-nav a { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; }
.footer-nav a:hover { color: var(--red); }

@media (max-width: 820px) {
  .header-inner { width: min(calc(100% - 32px), var(--page)); gap: 20px; }
  .brand-name { display: none; }
  .primary-nav { gap: 18px; }
  .header-search { width: clamp(200px, 32vw, 300px); }
  .poem-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .poem-card { padding: 28px 2px 20px; }
  .result-item { grid-template-columns: 170px minmax(0, 1fr); gap: 22px; }
  .result-source { display: none; }
}

@media (max-width: 620px) {
  .header-inner { min-height: 64px; flex-wrap: wrap; gap: 12px; padding: 12px 0; }
  .seal { width: 34px; height: 34px; font-size: 14px; }
  .primary-nav { gap: 13px; margin-left: auto; }
  .primary-nav a, .primary-nav button { font-size: 14px; letter-spacing: 0.09em; }
  .header-search { display: flex; width: 100%; flex-basis: 100%; margin-left: 0; }
  .header-search input { font-size: 16px; }
  .page-shell { width: min(calc(100% - 32px), var(--page)); }
  .daily-section { padding: 52px 0 64px; }
  .eyebrow { flex-direction: column; gap: 10px; }
  .daily-poem h1, .poem-title { letter-spacing: 0.1em; }
  .poem-lines { margin: 38px auto; letter-spacing: 0.05em; }
  .section-rule { margin-top: 80px; }
  .section-rule h2 { font-size: 21px; letter-spacing: 0.2em; }
  .poem-grid { grid-template-columns: 1fr; }
  .poem-card { min-height: auto; padding: 24px 2px 20px; }
  .discovery-section { padding: 32px 0 56px; }
  .discovery-heading { align-items: flex-start; flex-direction: column; gap: 18px; margin-bottom: 24px; }
  .discovery-heading h2 { font-size: 25px; }
  .discovery-link { flex-direction: row; align-items: center; justify-content: flex-start; gap: 16px; }
  .poem-grid { gap: 20px; }
  .footer-inner { width: calc(100% - 32px); flex-direction: column; align-items: flex-start; gap: 20px; }
  .footer-identity { flex-wrap: wrap; gap: 16px; }
  .footer-nav { gap: 32px; }
  .browse-page, .favorites-page { padding: 46px 0 82px; }
  .filter-label { width: 100%; margin-top: 7px; }
  .result-item { grid-template-columns: 1fr; gap: 12px; padding: 24px 4px; }
  .result-item h2 { font-size: 20px; }
  .detail-page { padding: 40px 0 82px; }
  .poem-article { margin-top: 30px; }
  .detail-lines { margin-top: 42px; letter-spacing: 0.05em; }
  .source-panel { margin-top: 70px; padding: 24px 20px; }
  .source-grid { grid-template-columns: 1fr; }
  .neighbor-row { grid-template-columns: 1fr; }
  .neighbor-row button:last-child { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .poem-card, .poem-card h3 { transition: none; }
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; }
}

/* Personal reading space */
.favorites-page { max-width: 880px; }
.my-identity { display: flex; align-items: center; gap: 16px; padding-bottom: 40px; margin-bottom: 36px; border-bottom: 1px solid var(--line); }
.my-avatar { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 50%; background: var(--paper-deep, #ebe5db); overflow: hidden; display: grid; place-items: center; font-size: 28px; }
.my-avatar img { width: 100%; height: 100%; }
.my-avatar img, #profile-preview { object-fit: cover; border-radius: 50%; }
.my-identity h2 { font-size: 18px; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; font-weight: 500; margin: 4px 0 0; overflow-wrap: anywhere; }
.my-eyebrow { font-size: 12px; letter-spacing: .12em; color: var(--ink-soft); }
.my-identity > button { margin-left: auto; flex-shrink: 0; }
.my-secondary, .my-primary, .profile-form, .my-eyebrow, .my-collection-heading a { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; }
.my-secondary, .my-primary { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px; border: 1px solid var(--line); border-radius: 6px; background: transparent; font-size: 14px; color: var(--ink); cursor: pointer; }
.my-secondary:hover { background: rgba(39,30,21,.04); }
.my-primary { background: var(--red); border-color: var(--red); color: #fff; }
.my-primary:disabled { opacity: .6; cursor: wait; }
.my-collection-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.my-collection-heading h2 { margin: 0; font-size: 24px; font-weight: 500; }
.my-collection-heading a { font-size: 13px; min-height: 44px; display: inline-flex; align-items: center; color: var(--ink-soft); }
.profile-form { max-width: 480px; margin: -8px 0 40px; padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.4); }
.profile-form[hidden] { display: none; }
.profile-form h2 { margin: 0 0 24px; font-size: 18px; font-weight: 600; }
.profile-avatar-row { display: flex; align-items: center; gap: 20px; }
.profile-form > label { display: block; margin: 24px 0 8px; font-size: 14px; }
.profile-form input[name="nickname"] { width: 100%; padding: 10px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; }
.profile-help { color: var(--ink-soft); font-size: 12px; line-height: 1.6; margin-top: 8px; }
#profile-feedback { font-size: 13px; color: var(--red); margin-top: 12px; }
.profile-actions { display: flex; gap: 12px; margin-top: 24px; }
@media (max-width: 620px) {
  .my-identity { flex-wrap: wrap; gap: 16px; padding-bottom: 28px; margin-bottom: 24px; }
  .my-identity h2 { font-size: 18px; }
  .my-identity > div:nth-child(2) { flex: 1; min-width: 0; }
  .my-identity > button { margin-left: 72px; }
  .profile-form { padding: 20px; }
}

/* Profile overview and collection use separate reading-space sections. */
.favorites-page { max-width: 840px; min-height: 65vh; padding-top: 48px; }
.my-tabs { display: flex; gap: 32px; margin-bottom: 44px; border-bottom: 1px solid var(--line); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; }
.my-tabs a { display: inline-flex; align-items: center; min-height: 48px; padding-bottom: 12px; color: var(--ink-soft); font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.my-tabs a[aria-current="page"] { border-color: var(--red); color: var(--ink); }
.my-page-title { font-size: 30px; font-weight: 500; letter-spacing: .06em; margin: 0 0 12px; }
.my-page-description { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; color: var(--ink-soft); font-size: 13px; line-height: 1.7; margin: 0 0 36px; }
.my-identity { padding: 24px; margin-bottom: 32px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.32); }
.my-identity h2 { line-height: 1.5; }
.profile-form { max-width: 100%; padding: 32px; margin: 0 0 32px; }
.profile-form input[name="nickname"] { max-width: 420px; transition: border-color .15s; }
.profile-form input[name="nickname"]:focus { outline: none; box-shadow: none; border: 1px solid var(--red); }
.my-empty { display: flex; flex-direction: column; align-items: center; padding: 76px 24px 88px; border-top: 1px solid var(--line); }
.my-empty svg { color: #938779; margin-bottom: 24px; }
.my-empty h2 { margin: 0 0 14px; font-size: 22px; line-height: 1.5; font-weight: 500; letter-spacing: .04em; }
.my-empty p { line-height: 1.8; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; }
.my-empty .my-secondary { margin-top: 32px; min-width: 140px; padding: 12px 24px; }
@media (max-width: 620px) {
  .favorites-page { padding-top: 32px; }
  .my-tabs { margin-bottom: 32px; gap: 28px; }
  .my-page-title { font-size: 26px; }
  .my-identity { padding: 24px 20px; }
  .profile-form { padding: 24px 20px; }
  .my-empty { padding: 56px 16px 72px; }
}

.reading-nav button { border: 0; background: transparent; color: inherit; font: inherit; padding: 8px 0; min-height: 44px; cursor: pointer; }

/* Poet directory and shared reading */
.poets-heading { display: flex; align-items: center; justify-content: space-between; gap: 40px; margin-bottom: 36px; }
.poets-heading .page-kicker { margin-bottom: 0; }
.poets-heading .large-search { width: 280px; flex: 0 0 280px; margin: 0; }
.poets-heading .large-search input { font-size: 15px; padding: 14px 0; min-width: 0; }
.poets-heading .large-search button { font-size: 14px; }
.dynasty-tabs { display: flex; flex-wrap: wrap; gap: 0 26px; border-bottom: 1px solid var(--line); }
.dynasty-tab { position: relative; border: 0; border-bottom: 2px solid transparent; padding: 14px 0; background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 16px; min-height: 48px; }
.dynasty-tab.active { color: var(--red); border-bottom-color: var(--red); }
.dynasty-tab:hover { color: var(--red); }
.dynasty-tab:focus-visible { outline: 1px solid var(--red); outline-offset: 4px; }
.poets-intro { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 36px 0 8px; }
.poets-intro h2 { margin: 0; font-size: 17px; font-weight: 500; letter-spacing: .08em; }
.poets-intro p { margin: 0; font-size: 12px; color: var(--ink-soft); }
.poet-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 40px; }
.poet-card { display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 27px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.poet-card h3 { margin: 0; font-size: 23px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; transition: color .15s; }
.poet-card p { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.poet-card:hover h3, .poet-card:focus-visible h3 { color: var(--red); }
.poet-card:focus-visible { outline: 1px solid var(--red); outline-offset: 5px; }
.comments-panel { text-align: left; margin-top: 52px; padding-top: 32px; border-top: 1px solid var(--line); scroll-margin-top: 95px; }
.comments-panel h2 { font-size: 23px; }
.comment-login { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0; }
.comment-login p, .comment-status { color: var(--ink-soft); font-size: 14px; }
#comment-form { margin-top: 24px; }
#comment-form label { display: block; margin: 20px 0 10px; font-size: 14px; }
#comment-content { display: block; width: 100%; box-sizing: border-box; resize: vertical; padding: 16px; background: transparent; border: 1px solid var(--line); color: var(--ink); font: inherit; font-size: 15px; line-height: 1.8; }
#comment-content:focus { outline: none; box-shadow: none; border-color: rgba(38, 34, 30, .55); }
.comment-form-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.comment-form-foot span, #comment-feedback { font-size: 13px; color: var(--ink-soft); }
#comment-list { margin-top: 32px; }
.comment-item:first-child { border-top: 1px solid var(--line); }
.comment-item { padding: 22px 0; border-bottom: 1px solid var(--line); }
.comment-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.comment-meta time { color: var(--ink-soft); font-size: 12px; }
.comment-item p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.9; margin-bottom: 0; }
#comment-more { margin-top: 20px; }
.detail-actions a { text-decoration: none; }
@media (max-width: 850px) { .poet-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 28px; } }
@media (max-width: 560px) {
  .poets-heading { align-items: stretch; flex-direction: column; gap: 24px; margin-bottom: 22px; }
  .poets-heading .large-search { width: 100%; flex: auto; }
  .dynasty-tabs { gap: 0 23px; }
  .dynasty-tab { font-size: 15px; }
  .poet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
  .poet-card { padding: 22px 0; }
  .poet-card h3 { font-size: 21px; }
  .poets-intro { margin-top: 28px; }
  .comment-login { align-items: flex-start; flex-direction: column; }
  .comment-meta { flex-direction: column; gap: 4px; }
}
@media (max-width: 360px) { .header-inner { column-gap: 8px; } .primary-nav { gap: 10px; } }

.author-back { display: inline-block; margin: 0 0 34px; font-size: 13px; }
.author-hero { display: grid; grid-template-columns: minmax(160px, 220px) minmax(0, 1fr); column-gap: 64px; align-items: start; padding: 0 0 38px; margin-bottom: 38px; border-bottom: 1px solid var(--line); }
.author-identity { padding-top: 3px; }
.author-name { letter-spacing: .16em; line-height: 1.4; overflow-wrap: anywhere; }
.author-lifespan { margin: 14px 0 0; font-size: 14px; color: var(--ink-soft); line-height: 1.8; letter-spacing: .03em; }
.author-seal { display: block; width: 30px; height: 2px; background: var(--red); opacity: .7; margin-top: 28px; }
.poet-profile { min-width: 0; }
.poet-profile-meta { font-size: 13px; color: var(--ink-soft); letter-spacing: .14em; margin: 0 0 14px; }
.poet-profile-title { font-size: 14px; font-weight: 500; color: var(--red); letter-spacing: .15em; margin: 0 0 16px; }
.poet-introduction { font-size: 16px; line-height: 2; white-space: pre-wrap; margin: 0; text-align: justify; }
.poet-introduction-pending { font-size: 15px; line-height: 1.9; color: var(--ink-soft); margin: 0; }
.poet-sources { margin-top: 18px; color: var(--ink-soft); font-size: 12px; line-height: 1.8; }
.poet-sources summary { cursor: pointer; width: fit-content; }
.poet-sources a { display: block; margin-top: 8px; text-decoration: underline; overflow-wrap: anywhere; }
.author-works-title { font-size: 23px; font-weight: 500; letter-spacing: .12em; margin: 0; }
.author-works-title + .large-search { margin-top: 20px; }
@media (max-width: 680px) {
  .author-back { margin-bottom: 26px; }
  .author-hero { grid-template-columns: minmax(0, 1fr); row-gap: 28px; padding-bottom: 30px; margin-bottom: 30px; }
  .author-seal { margin-top: 18px; }
  .author-name { font-size: 36px; }
  .poet-profile-meta { margin-bottom: 8px; }
  .poet-profile-title { margin-bottom: 12px; }
  .poet-introduction { line-height: 1.95; }
}

/* Reading actions and persistent section navigation */
.detail-actions { display: flex; justify-content: center; align-items: center; gap: 20px; }
.poem-action { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; flex: 0 0 52px; padding: 0; border: 1px solid rgba(38, 34, 30, .24); border-radius: 50%; background: rgba(255, 255, 255, .4); color: var(--ink-soft); cursor: pointer; transition: background-color .18s, border-color .18s, color .18s; }
.poem-action svg { flex: 0 0 auto; }
.poem-action.saved { color: var(--red); border-color: var(--red); background: rgba(168, 64, 47, .08); }
.poem-action.saved svg { fill: currentColor; }
.poem-action:hover { color: var(--red); border-color: var(--red); background: var(--paper-deep); }
.poem-action:active { background: rgba(168, 64, 47, .12); }
.poem-action .comment-count { top: -4px; right: -5px; }
.poem-action:focus-visible { outline: 1px solid var(--red); outline-offset: 4px; }
.comment-count { position: absolute; display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; box-sizing: border-box; padding: 0 5px; border: 0; border-radius: 12px; background: #f1ddd5; color: var(--red); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; font-size: 11px; line-height: 1; font-variant-numeric: tabular-nums; }
.comment-count[hidden] { display: none; }
.comment-nav-label { position: relative; display: inline-block; margin-right: 14px; }
.comment-nav-label .comment-count { top: -8px; left: calc(100% - 1px); }
.reading-nav { position: sticky; top: var(--poem-header-height, 72px); z-index: 15; background: var(--paper); padding: 10px 0; }
.reading-nav button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.reading-section, .comments-panel { scroll-margin-top: calc(var(--poem-header-height, 72px) + var(--poem-reading-nav-height, 65px) + 20px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Keep the complete reading title on one line; fit its font to the container. */
.poem-title { text-wrap: nowrap; line-height: 1.4; }
.poem-title span { display: inline-block; white-space: nowrap; }

.detail-lines p.annotated-stanza { margin: 0; text-align: left; line-height: 1.8; }
.detail-lines .annotated-stanza + .annotated-stanza { margin-top: 1em; }
