:root {
  color-scheme: light;
  --paper: #fbfbf7;
  --page-bg:
    radial-gradient(circle at 14% 18%, rgba(255, 198, 225, .10), transparent 30%),
    radial-gradient(circle at 82% 12%, rgba(192, 229, 255, .09), transparent 32%),
    radial-gradient(circle at 88% 78%, rgba(205, 244, 215, .08), transparent 34%),
    radial-gradient(circle at 18% 84%, rgba(255, 239, 190, .08), transparent 30%),
    linear-gradient(135deg, #fffefe 0%, #fdfefe 42%, #fffefb 100%);
  --ink: #1f2321;
  --muted: #8b8f8b;
  --line: #dcded8;
  --button-bg: rgba(251, 251, 247, .86);
  --panel-bg: rgba(251, 251, 247, .98);
}

:root[data-theme="night"] {
  color-scheme: dark;
  --paper: #111312;
  --page-bg: var(--paper);
  --ink: #e4e0d4;
  --muted: #8d938f;
  --line: #343936;
  --button-bg: rgba(17, 19, 18, .82);
  --panel-bg: rgba(17, 19, 18, .98);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--ink);
  font-family: ui-serif, "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  letter-spacing: 0;
}

body, .pillBtn, .pagerBtn, .archivePanel, .archiveHeader, .archiveTools, .archivePager, .archiveItem, .closeBtn, select {
  transition: background 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              background-color 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              color 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

button {
  font: inherit;
  letter-spacing: 0;
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 72px 24px;
}

.today {
  width: min(100%, 760px);
  display: grid;
  justify-items: center;
  gap: 22px;
}

.poem {
  width: 100%;
  text-align: center;
  white-space: pre-wrap;
  font-size: clamp(20px, 3.8vw, 36px);
  line-height: 2.05;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.poemLine {
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  filter: blur(2px);
  animation: poemFadeIn 1.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.poemMeta {
  min-height: 22px;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.65;
  text-align: center;
  opacity: 0;
  animation: metaFadeIn 1.2s ease forwards;
  animation-delay: 1.2s;
}

.poem[data-status="missing"] {
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

@keyframes poemFadeIn {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes metaFadeIn {
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-delay: 0s !important;
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    scroll-behavior: auto !important;
  }
  .poemLine, .poemMeta {
    opacity: 1 !important;
    transform: none !important;
  }
}

.actions {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  gap: 10px;
}

.pillBtn,
.pagerBtn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--button-bg);
  color: var(--ink);
  padding: 9px 16px;
  cursor: pointer;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
}

a.pillBtn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.pillBtn:hover,
.pagerBtn:hover,
.closeBtn:hover {
  border-color: var(--muted);
}

.pagerBtn:disabled {
  cursor: default;
  opacity: .45;
}

.archivePanel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--panel-bg);
}

.archivePanel.open {
  display: grid;
}

.archiveHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.archiveHeader h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 400;
}

.archiveStats {
  min-height: 18px;
  margin: 6px 0 0;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.4;
}

.closeBtn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.archiveTools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.archiveTools label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.archiveTools select {
  min-width: 138px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--ink);
  padding: 0 30px 0 10px;
  font: inherit;
  font-size: 14px;
}

.archiveList {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(var(--archive-columns, 3), minmax(0, 1fr));
  grid-auto-rows: auto;
  gap: 18px;
}

.archiveItem {
  min-width: 0;
  min-height: 168px;
  padding: 12px 12px 14px;
  border-top: 1px solid var(--line);
  text-align: left;
  white-space: pre-wrap;
  font-size: clamp(14px, 1.8vw, 20px);
  line-height: 1.85;
  overflow: hidden;
  display: grid;
  align-content: center;
}

.archiveTime {
  margin: 0 0 8px;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.4;
}

.archiveTone {
  margin-top: 8px;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.4;
}

.archiveText {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: center;
}

.archiveEmpty {
  grid-column: 1 / -1;
  place-self: center;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
}

.archivePager {
  min-height: 64px;
  padding: 12px 24px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-top: 1px solid var(--line);
  font-family: ui-sans-serif, system-ui, sans-serif;
  color: var(--muted);
  font-size: 14px;
}

.shareModal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 24px;
}

.shareModal.open {
  display: grid;
}

.shareModalContent {
  width: min(100%, 420px);
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.shareModalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shareModalHeader h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 400;
}

.shareTip {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.shareImgContainer {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.shareImgContainer img {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 6px;
  border: 1px solid var(--line);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

@media (max-width: 620px) {
  .page {
    padding: 56px 18px;
  }

  .poem {
    font-size: clamp(20px, 8vw, 32px);
    line-height: 2;
  }

  .actions {
    right: 16px;
    bottom: 16px;
  }

  .archiveHeader {
    padding: 18px;
  }

  .archiveTools {
    padding: 12px 18px;
  }

  .archiveTools label {
    flex: 1 1 128px;
  }

  .archiveTools select {
    width: 100%;
    min-width: 0;
  }

  .archiveList {
    padding: 18px;
    gap: 12px;
  }

  .archiveItem {
    min-height: 142px;
  }

  .archivePager {
    min-height: 54px;
    gap: 10px;
  }
}
