﻿:root {
  --bg: #f5efe4;
  --paper: rgba(255, 252, 245, 0.92);
  --paper-strong: #fffaf0;
  --ink: #30261d;
  --muted: #7e6c5d;
  --line: rgba(116, 83, 54, 0.18);
  --accent: #a65f2b;
  --accent-dark: #773d1c;
  --accent-soft: rgba(166, 95, 43, 0.12);
  --shadow: 0 24px 60px rgba(83, 57, 34, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(196, 124, 65, 0.22), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(132, 79, 42, 0.16), transparent 28rem),
    linear-gradient(135deg, #f8f0df 0%, #efe3cf 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(93, 63, 37, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(93, 63, 37, 0.05) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent 70%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: "STKaiti", "KaiTi", "Microsoft YaHei UI", serif;
  letter-spacing: 0.03em;
}

h1 {
  font-size: clamp(34px, 5vw, 54px);
}

h2 {
  font-size: 26px;
}

.tabs {
  display: flex;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.72);
  box-shadow: 0 12px 30px rgba(83, 57, 34, 0.08);
}

.tab {
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: 0.2s ease;
}

.tab:hover,
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 10px 22px rgba(119, 61, 28, 0.22);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

#readerView {
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 22px;
}

#readerView.active {
  display: grid;
}

.card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.poem-menu {
  position: sticky;
  top: 24px;
  height: calc(100vh - 112px);
  min-height: 620px;
  padding: 22px;
  overflow: hidden;
}

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 34px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 700;
}

.search-box {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 14px;
}

.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
  outline: none;
}

.search-box input:focus {
  border-color: rgba(166, 95, 43, 0.58);
  box-shadow: 0 0 0 4px rgba(166, 95, 43, 0.1);
}

.poem-list {
  display: grid;
  gap: 10px;
  max-height: calc(100% - 150px);
  overflow: auto;
  padding-right: 4px;
}

.poem-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 13px 14px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.46);
  cursor: pointer;
  transition: 0.2s ease;
}

.poem-button:hover,
.poem-button.active {
  border-color: rgba(166, 95, 43, 0.35);
  background: linear-gradient(135deg, rgba(166, 95, 43, 0.16), rgba(255, 255, 255, 0.78));
  transform: translateX(3px);
}

.poem-button small {
  color: var(--muted);
}

.poem-content {
  min-height: 620px;
  padding: clamp(26px, 4vw, 54px);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 500px;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  margin-bottom: 18px;
  border-radius: 50%;
  color: #fff;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 42px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 18px 35px rgba(119, 61, 28, 0.2);
}

.hidden {
  display: none;
}

.detail-title {
  position: relative;
  padding-bottom: 24px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--line);
}

.detail-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 110px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

.detail-title h2 {
  font-size: clamp(34px, 5vw, 52px);
}

.author {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  color: #2b2118;
  font-family: "STKaiti", "KaiTi", "FangSong", "Microsoft YaHei UI", serif;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 2;
  letter-spacing: 0.08em;
}

.reader-navigation {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 36px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.reader-navigation button {
  min-width: 112px;
  border: 1px solid rgba(166, 95, 43, 0.38);
  border-radius: 16px;
  padding: 12px 18px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.58);
  cursor: pointer;
}

.reader-navigation button:hover:not(:disabled) {
  color: #fff;
  background: var(--accent);
}

.chain-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 22px;
}

.chain-card {
  padding: 30px;
}

.muted {
  color: var(--muted);
  line-height: 1.8;
}

.chain-controls {
  display: flex;
  gap: 12px;
  margin: 24px 0;
}

.chain-controls select {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
}

.chain-controls button,
.chain-option,
.answer-row button,
.chain-actions button {
  border: 0;
  border-radius: 16px;
  padding: 12px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  cursor: pointer;
}

.chain-current {
  min-height: 120px;
  border: 1px dashed rgba(166, 95, 43, 0.34);
  border-radius: 22px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.42);
}

.question-label { margin: 0 0 16px; color: var(--muted); }
.question-label strong { margin-left: 5px; color: var(--accent-dark); }
blockquote { margin: 0; font-family: "STKaiti", "KaiTi", serif; font-size: clamp(25px, 4vw, 38px); line-height: 1.7; }
.answer-form { display: grid; gap: 9px; margin-top: 22px; color: var(--muted); font-size: 14px; }
.answer-row, .chain-actions { display: flex; gap: 12px; }
.answer-row input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 16px; padding: 13px 15px; color: var(--ink); background: rgba(255, 255, 255, 0.72); outline: none; }
.answer-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.chain-feedback { min-height: 52px; margin: 14px 0; padding: 14px 16px; border-radius: 16px; }
.chain-feedback:empty { padding: 0; }
.chain-feedback.correct { color: #28633c; background: #e5f3e9; }
.chain-feedback.wrong { color: #8a382d; background: #f8e8e5; }
.chain-feedback.answer { color: var(--accent-dark); background: var(--accent-soft); }
.chain-actions { justify-content: flex-end; }
.chain-actions .secondary-button { color: var(--accent-dark); border: 1px solid rgba(166, 95, 43, 0.4); background: transparent; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
.score-board { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 26px 0; }
.score-board div { display: grid; gap: 4px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, 0.42); }
.score-board strong { font-size: 32px; color: var(--accent-dark); }
.score-board span { color: var(--muted); }
.source-note { border-top: 1px solid var(--line); padding-top: 20px; }

.chain-options {
  display: grid;
  gap: 12px;
}

.chain-option {
  width: 100%;
  text-align: left;
  background: rgba(166, 95, 43, 0.86);
}

.notice {
  padding: 18px;
  border: 1px solid rgba(166, 95, 43, 0.28);
  border-radius: 18px;
  color: var(--accent-dark);
  background: rgba(166, 95, 43, 0.1);
}

@media (max-width: 860px) {
  .topbar,
  .chain-controls,
  .answer-row {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    justify-content: center;
  }

  #readerView.active,
  .chain-layout {
    grid-template-columns: 1fr;
  }

  .poem-menu {
    position: static;
    height: auto;
    min-height: 0;
  }

  .poem-list {
    max-height: 360px;
  }
}
