@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600&display=swap');

:root,
[data-theme='light'] {
  --bg: #f4f1ea;
  --surface: #faf8f4;
  --text: #2a2520;
  --muted: #6b6259;
  --accent: #6b5344;
  --border: #ddd4c8;
  --btn-bg: #ebe4d8;
  --btn-hover: #e0d5c6;
  --shadow: rgba(50, 38, 28, 0.08);
}

[data-theme='sepia'] {
  --bg: #ebe3d4;
  --surface: #f5efe3;
  --text: #3d2f24;
  --muted: #7a6656;
  --accent: #5c4330;
  --border: #cfc2ae;
  --btn-bg: #e4d9c8;
  --btn-hover: #d8cab5;
  --shadow: rgba(70, 52, 32, 0.1);
}

[data-theme='dark'] {
  --bg: #1c1a18;
  --surface: #252220;
  --text: #e8e2d8;
  --muted: #a69a8c;
  --accent: #c9a882;
  --border: #3a3530;
  --btn-bg: #322e2a;
  --btn-hover: #3d3832;
  --shadow: rgba(0, 0, 0, 0.35);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family:
    'Noto Serif SC',
    'Songti SC',
    'STSong',
    'SimSun',
    serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.06em;
}

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

.site-nav {
  display: flex;
  gap: 0.75rem;
  font-size: 0.95rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--muted);
}

.site-nav a[aria-current='page'] {
  color: var(--accent);
  font-weight: 600;
}

.layout {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.hero {
  padding: 2.5rem 0 2rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(1.65rem, 5vw, 2rem);
  font-weight: 600;
  margin: 0 0 0.75rem;
  letter-spacing: 0.12em;
}

.hero .tagline {
  color: var(--muted);
  margin: 0 0 2rem;
  font-size: 1rem;
}

.cards {
  display: grid;
  gap: 1rem;
}

@media (min-width: 520px) {
  .cards {
    grid-template-columns: 1fr 1fr;
  }
}

.card-link {
  display: block;
  padding: 1.5rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  box-shadow: 0 1px 2px var(--shadow);
  transition: background 0.15s ease;
}

.card-link:hover,
.card-link:focus-visible {
  background: var(--btn-hover);
}

.card-link h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.card-link p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.site-footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.6;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.toolbar label {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn,
select,
input[type='number'] {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  border-radius: 6px;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
}

.btn:hover {
  background: var(--btn-hover);
}

.btn-primary {
  background: var(--accent);
  color: var(--surface);
  border-color: transparent;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.toc {
  margin: 0 0 1.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.toc h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.toc ol {
  margin: 0;
  padding-left: 1.25rem;
}

.toc li {
  margin: 0.35rem 0;
}

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

.toc a[aria-current='true'] {
  color: var(--accent);
  font-weight: 600;
}

.reader-article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.15rem 2rem;
  box-shadow: 0 1px 3px var(--shadow);
}

.reader-article .sutra-title {
  text-align: center;
  font-size: 1.35rem;
  margin: 0 0 0.25rem;
}

.reader-article .pin-title {
  text-align: center;
  font-size: 1.1rem;
  margin: 1.5rem 0 1rem;
  color: var(--accent);
}

.reader-article .byline {
  text-align: center;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.kaijing {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px dashed var(--border);
}

.kaijing h3 {
  text-align: center;
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.kaijing p,
.sutra-para,
.sutra-verse {
  margin: 0 0 1rem;
  text-indent: 2em;
}

.sutra-verse {
  text-indent: 0;
  padding-left: 1em;
}

.pinyin {
  display: block;
  font-size: 0.78em;
  color: var(--muted);
  text-indent: 0;
  margin-bottom: 0.35rem;
  line-height: 1.4;
  font-family: system-ui, sans-serif;
  letter-spacing: 0.02em;
}

.counter-panel {
  text-align: center;
  padding: 1rem 0 2rem;
}

.counter-name {
  font-size: clamp(1.25rem, 4vw, 1.65rem);
  margin: 0 0 1.5rem;
  letter-spacing: 0.08em;
}

.counter-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.stat {
  text-align: center;
}

.stat dt {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.stat dd {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
}

.tap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(16rem, 80vw);
  height: min(16rem, 80vw);
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1.5;
  padding: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--shadow);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.08s ease,
    background 0.15s ease;
}

.tap-btn:active {
  transform: scale(0.97);
  background: var(--btn-hover);
}

.goal-bar {
  max-width: 20rem;
  margin: 0 auto 1.25rem;
}

.goal-bar progress {
  width: 100%;
  height: 0.5rem;
}

.counter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.huixiang {
  margin-top: 2rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.05rem;
  line-height: 1.9;
}

.huixiang h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
  color: var(--accent);
  text-align: center;
}

.huixiang p {
  margin: 0;
  text-indent: 2em;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  max-width: 22rem;
  width: 100%;
}

.dialog p {
  margin: 0 0 1rem;
}

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.hidden {
  display: none !important;
}

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

/* Breadcrumb */
.breadcrumb {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.breadcrumb ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

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

.breadcrumb [aria-current='page'] {
  color: var(--text);
}

.breadcrumb .crumb-sep {
  color: var(--border);
}

/* Intro / lede copy */
.lede {
  color: var(--muted);
  font-size: 1.02rem;
  margin: 0 0 1.5rem;
}

.section-title {
  font-size: 1.15rem;
  margin: 2rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

/* 13-pin grid used on home + hub pages */
.pin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
}

@media (min-width: 560px) {
  .pin-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.pin-grid a {
  display: block;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.5;
}

.pin-grid a:hover {
  background: var(--btn-hover);
}

.pin-grid .pin-no {
  color: var(--accent);
  font-weight: 600;
  margin-right: 0.3em;
}

/* Hub links row (全文 / 拼音版) */
.hub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0 0 1.5rem;
}

.hub-links a {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  font-size: 0.92rem;
}

.hub-links a:hover {
  background: var(--btn-hover);
}

/* Prev/next pin navigation */
.pin-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1.5rem 0 0;
}

.pin-nav a {
  flex: 1;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.4;
}

.pin-nav a:hover {
  background: var(--btn-hover);
}

.pin-nav .pin-nav-next {
  text-align: right;
}

.pin-nav .pin-nav-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.15rem;
}

/* Articles index */
.article-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.article-card {
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.article-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.article-card h2 a {
  text-decoration: none;
  color: var(--text);
}

.article-card h2 a:hover {
  color: var(--accent);
}

.article-card .article-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.article-card p.excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.tag-chip {
  display: inline-block;
  font-size: 0.74rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  margin: 0 0.3rem 0.3rem 0;
}

/* Article page typography */
.article-header {
  margin-bottom: 1.5rem;
}

.article-header h1 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

.article-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.article-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.25rem 1.5rem;
  font-size: 1.02rem;
}

.article-body h2 {
  font-size: 1.2rem;
  margin: 1.75rem 0 0.75rem;
}

.article-body h3 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.6rem;
}

.article-body p {
  margin: 0 0 1rem;
}

.article-body ul,
.article-body ol {
  margin: 0 0 1rem;
  padding-left: 1.4rem;
}

.article-body li {
  margin: 0.3rem 0;
}

.article-body blockquote {
  margin: 0 0 1rem;
  padding: 0.6rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--bg);
  color: var(--text);
  font-size: 0.98rem;
}

.article-body blockquote p {
  margin: 0;
}

.article-body a {
  text-decoration-thickness: 1px;
}

.related-box {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.related-box h2 {
  font-size: 1rem;
  margin: 0 0 0.6rem;
}

.related-box ul {
  margin: 0;
  padding-left: 1.2rem;
}

.related-box li {
  margin: 0.25rem 0;
}

/* Full-text / pinyin pages */
.quanwen-article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.15rem 2rem;
  box-shadow: 0 1px 3px var(--shadow);
}

.quanwen-toc {
  margin: 0 0 1.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.quanwen-toc ol {
  margin: 0;
  padding-left: 1.25rem;
  columns: 2;
}

@media (max-width: 480px) {
  .quanwen-toc ol {
    columns: 1;
  }
}

.quanwen-toc a {
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
}

/* 404 */
.notfound {
  text-align: center;
  padding: 3rem 0;
}

.notfound h1 {
  font-size: 2.5rem;
  margin: 0 0 0.5rem;
  color: var(--accent);
}

.continue-link {
  border-color: var(--accent);
}

noscript .notice {
  display: block;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  margin-bottom: 1rem;
}
