:root {
  --bg: #faf9f6;
  --card: #ffffff;
  --text: #211f1c;
  --muted: #8a867c;
  --faint: #b3afa5;
  --border: #e8e5dd;
  --accent: #a4512c;
  --accent-soft: #f4e8e1;
  --serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", STSong, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1917;
    --card: #211f1d;
    --text: #e9e6df;
    --muted: #8f8b81;
    --faint: #6a675e;
    --border: #33312c;
    --accent: #d9946c;
    --accent-soft: #33261f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 20px 32px;
}

.masthead { text-align: center; margin-bottom: 32px; }

.brand {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: 2px;
  margin: 0;
}

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

.page-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

.identity-note {
  margin: 8px 0 0;
  color: var(--faint);
  font-size: 12px;
}

.identity-note a {
  color: inherit;
  text-decoration: none;
}

.identity-note a:hover {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.home-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.home-page .masthead { margin-top: 14vh; }

.home-page .footer { margin-top: auto; }

.ask { margin-bottom: 36px; }

.ask-form {
  display: flex;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 6px 6px 20px;
  transition: border-color 0.15s;
}

.ask-form:focus-within { border-color: var(--accent); }

.ask-form input {
  flex: 1;
  border: none;
  background: none;
  color: var(--text);
  font-size: 15px;
  font-family: var(--sans);
  outline: none;
  min-width: 0;
}

.ask-form input::placeholder { color: var(--faint); }

.ask-form button {
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-family: var(--sans);
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
}

.ask-form button:disabled { opacity: 0.5; cursor: wait; }

.ask-hint { text-align: center; font-size: 12px; color: var(--faint); margin: 14px 0 0; }

.ask-result {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}

.ask-answer {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 2;
  white-space: pre-wrap;
}

.ask-answer.typing::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 1em;
  margin-left: 2px;
  background: var(--accent);
  vertical-align: -0.12em;
  animation: caret-blink 0.9s steps(1) infinite;
}

.ask-answer .cite-mark { color: var(--accent); font-size: 12px; }

.ask-citations { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 6px; }

.thinking-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
}

.thinking-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinking-pulse 1.2s ease-in-out infinite;
}

.source-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 72px 84px 48px;
  align-items: baseline;
  column-gap: 10px;
  padding: 6px 0;
  color: var(--muted);
  font-size: 12px;
}

.source-row .cite-mark {
  color: var(--accent);
  font-size: 12px;
}

.citation-text,
.citation-platform,
.citation-date {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.citation-text { color: var(--muted); }

.citation-author {
  color: var(--text);
  margin-right: 6px;
  font-weight: 600;
}

.citation-platform,
.citation-date { color: var(--faint); }

.source-link {
  justify-self: end;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.source-link:hover { text-decoration: underline; }

.source-link-muted {
  color: var(--faint);
  cursor: default;
}

.source-link-muted:hover { text-decoration: none; }

.ask-other {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.other-panel > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  font-size: 12px;
}

.other-panel > summary::-webkit-details-marker { display: none; }

.other-panel > summary::after {
  content: "展开";
  color: var(--faint);
  font-size: 12px;
}

.other-panel[open] > summary::after { content: "收起"; }

.other-count {
  margin-left: auto;
  color: var(--faint);
}

.other-list { margin-top: 10px; }

.other-answer {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.other-answer:first-child { border-top: none; }

.other-answer h3 {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.other-answer-body {
  margin: 6px 0 10px;
  color: var(--text);
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.9;
  white-space: pre-wrap;
}

.other-citations { display: grid; gap: 4px; }

.other-citation.source-row {
  grid-template-columns: 34px minmax(0, 1fr) 72px 84px 48px;
}

@media (max-width: 520px) {
  .source-row,
  .other-citation.source-row {
    grid-template-columns: 30px minmax(0, 1fr) 44px;
    row-gap: 2px;
  }

  .citation-platform {
    grid-column: 2;
    grid-row: 2;
    font-size: 11px;
  }

  .citation-date {
    grid-column: 2;
    grid-row: 3;
    font-size: 11px;
  }

  .source-link {
    grid-column: 3;
    grid-row: 1 / span 3;
    align-self: center;
  }
}

@keyframes caret-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes thinking-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

.toolbar { margin-bottom: 8px; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

.tag-chip {
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--sans);
  padding: 4px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}

.tag-chip:hover { border-color: var(--accent); color: var(--accent); }

.tag-chip.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.search input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--text);
  font-size: 14px;
  font-family: var(--sans);
  padding: 8px 2px;
  outline: none;
}

.search input:focus { border-bottom-color: var(--accent); }

.search input::placeholder { color: var(--faint); }

.quotes { margin-top: 8px; }

.pinned-page .masthead { margin-top: 6vh; }

.pinned-quotes {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.pinned-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.pinned-detail {
  padding: 18px 18px 16px;
}

.pinned-detail summary {
  cursor: pointer;
  list-style: none;
}

.pinned-detail summary::-webkit-details-marker { display: none; }

.pinned-detail summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 6px;
}

.pinned-preview {
  display: -webkit-box;
  overflow: hidden;
  max-height: 9.5em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.9;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.pinned-detail[open] .pinned-preview { display: none; }

.pinned-meta {
  margin-top: 12px;
  align-items: center;
}

.pinned-toggle {
  margin-left: auto;
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
}

.pinned-toggle::after { content: "展开全文"; }

.pinned-detail[open] .pinned-toggle::after { content: "收起"; }

.pinned-expanded {
  padding-top: 12px;
}

.pinned-full { font-size: 17px; }

.pinned-actions {
  margin: 12px 0 0;
  font-size: 12px;
}

.pinned-actions a {
  color: var(--accent);
  text-decoration: none;
}

.pinned-actions a:hover { text-decoration: underline; }

.quote {
  padding: 26px 0;
  border-bottom: 1px solid var(--border);
}

.quote-body {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 2;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.quote-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--faint);
}

.quote-author {
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: 0 7px;
  font-weight: 500;
}

.quote-meta a { color: var(--accent); text-decoration: none; }

.quote-meta a:hover { text-decoration: underline; }

.quote-tags { margin-left: auto; display: flex; gap: 6px; }

.quote-tag {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 8px;
  color: var(--muted);
  cursor: pointer;
  background: none;
  font-size: 11px;
  font-family: var(--sans);
}

.quote-tag:hover { color: var(--accent); border-color: var(--accent); }

.more-row { text-align: center; padding: 24px 0; }

.ghost-button {
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--sans);
  padding: 8px 28px;
  border-radius: 999px;
  cursor: pointer;
}

.ghost-button:hover { border-color: var(--accent); color: var(--accent); }

.list-note { font-size: 12px; color: var(--faint); margin: 12px 0 0; }

.empty-page {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.empty-page a {
  color: var(--accent);
  text-decoration: none;
}

.empty-page a:hover { text-decoration: underline; }

.footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  color: var(--faint);
}

.footer a { color: var(--faint); text-decoration: none; }

.footer a:hover { color: var(--accent); }

@media (max-width: 480px) {
  .page { padding-top: 32px; }
  .brand { font-size: 30px; }
  .quote-tags { margin-left: 0; width: 100%; }
}
