:root {
  color-scheme: light;
  --ink: #1f1b16;
  --muted: #5a5146;
  --accent: #c86a2e;
  --accent-deep: #9b4c1c;
  --panel: rgba(255, 255, 255, 0.86);
  --border: rgba(31, 27, 22, 0.12);
  --shadow: 0 18px 40px rgba(31, 27, 22, 0.12);
  --radius: 20px;
}

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

body {
  margin: 0;
  font-family: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fff5e5 0%, #f3e3c8 45%, #e7d6b8 100%);
  min-height: 100vh;
  position: relative;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(6px);
  z-index: -1;
}

body::before {
  top: -120px;
  right: -120px;
  background: radial-gradient(circle, rgba(200, 106, 46, 0.18), rgba(200, 106, 46, 0));
}

body::after {
  bottom: -180px;
  left: -120px;
  background: radial-gradient(circle, rgba(63, 87, 116, 0.16), rgba(63, 87, 116, 0));
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

.site-header {
  padding: 48px 24px 24px;
}

.header-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 8px;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.1;
}

.subhead {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
}

.ghost-button {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}

.ghost-button:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  color: var(--accent-deep);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-link {
  font-size: 14px;
  color: var(--muted);
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}

.nav-link:hover {
  color: var(--accent-deep);
  border-bottom-color: rgba(200, 106, 46, 0.4);
}

.nav-toggle {
  display: none;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.page {
  max-width: 980px;
  margin: 0 auto 64px;
  padding: 0 24px;
  display: grid;
  gap: 24px;
}

.list-page .page {
  max-width: none;
  padding: 0 16px 64px;
}

.list-page .header-inner {
  max-width: none;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
  backdrop-filter: blur(10px);
}

.controls {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 14px;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: white;
  color: var(--ink);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button {
  padding: 10px 14px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: white;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(200, 106, 46, 0.25);
}

.list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  margin: 0;
  font-size: 24px;
}

.count {
  color: var(--muted);
  font-size: 14px;
}

.status {
  margin: 12px 0 0;
  color: var(--muted);
}

.table-wrap {
  margin-top: 16px;
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
}

.poem-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.poem-table thead th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(200, 106, 46, 0.08);
}

.poem-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(31, 27, 22, 0.08);
  vertical-align: top;
}

.poem-table th:nth-child(1),
.poem-table td:nth-child(1) {
  width: 80px;
  white-space: nowrap;
}

.poem-table th:nth-child(2),
.poem-table td:nth-child(2) {
  width: 120px;
}

.poem-table th:nth-child(3),
.poem-table td:nth-child(3) {
  width: 160px;
}

.poem-table th:nth-child(4),
.poem-table td:nth-child(4) {
  width: 220px;
}

.poem-row {
  animation: rise 0.4s ease both;
  animation-delay: var(--delay, 0ms);
}

.poem-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.7);
}

.poem-row:hover {
  background: rgba(200, 106, 46, 0.12);
}

.poem-title-link {
  color: var(--ink);
  font-weight: 600;
}

.poem-title-link:hover {
  color: var(--accent-deep);
}

.poem-content-cell {
  color: var(--muted);
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-line;
}

.filter-link {
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.filter-link:hover {
  color: var(--accent-deep);
}

.filter-link:disabled {
  cursor: default;
  opacity: 0.6;
}

.expand-toggle {
  margin-left: 6px;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent-deep);
  cursor: pointer;
  font-weight: 600;
}

.expand-toggle:hover {
  color: var(--accent);
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-meta {
  margin: 6px 0 0;
  color: var(--muted);
}

.poem-content {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 18px;
}

.tag-list {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(200, 106, 46, 0.12);
  color: var(--accent-deep);
  font-size: 12px;
}

.challenge-page {
  gap: 20px;
}

.challenge-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.summary-value {
  font-size: 24px;
  font-weight: 600;
}

.challenge-card {
  display: grid;
  gap: 20px;
}

.challenge-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.challenge-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.challenge-label {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.challenge-prompt {
  margin: 0;
  font-size: 22px;
  line-height: 1.6;
}

.challenge-direction {
  margin: 6px 0 0;
  color: var(--accent-deep);
  font-weight: 600;
}

.answer-area label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--muted);
}

.answer-input-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
}

.answer-input-row input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.grid-area {
  display: grid;
  gap: 10px;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.grid-char {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: white;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.grid-char:hover {
  transform: translateY(-1px);
  border-color: rgba(200, 106, 46, 0.5);
}

.challenge-feedback {
  min-height: 24px;
  font-weight: 600;
}

.challenge-feedback.success {
  color: #1f7a2e;
}

.challenge-feedback.error {
  color: #b22a2a;
}

.answer-reveal {
  color: var(--muted);
}

.answer-reveal .reveal-line {
  margin: 0;
  font-weight: 600;
}

.answer-reveal .reveal-content {
  margin: 8px 0 0;
  white-space: pre-line;
  font: inherit;
}

.hidden {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .hide-on-mobile {
    display: none;
  }

  .site-nav {
    display: none;
    position: absolute;
    right: 0;
    top: 48px;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow);
    z-index: 10;
  }

  body.nav-open .site-nav {
    display: flex;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .site-header {
    padding-top: 36px;
  }

  .challenge-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .challenge-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .answer-input-row {
    grid-template-columns: 1fr;
  }

  .poem-content {
    font-size: 16px;
  }
}
