/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: "Noto Serif SC", "Source Han Serif CN", "Songti SC", Georgia, serif;
  color: #2c2c2c; background: #faf8f5; line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
a { color: #5a3e28; text-decoration: none; transition: color .2s; }
a:hover { color: #8b5e3c; }
img { max-width: 100%; height: auto; }

/* ========== Layout ========== */
.container { max-width: 960px; margin: 0 auto; padding: 0 1.5rem; }

/* ========== Nav ========== */
.site-nav {
  background: #3a2a1a; color: #e8ddd0; padding: .6rem 0;
  position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.site-nav .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.site-nav .logo { font-size: 1.3rem; color: #e8ddd0; font-weight: 700; letter-spacing: .05em; }
.site-nav .logo:hover { color: #fff; }
.nav-links { display: flex; gap: 1.2rem; list-style: none; flex-wrap: wrap; }
.nav-links a { color: #d4c5b0; font-size: .85rem; }
.nav-links a:hover { color: #fff; }

/* ========== Breadcrumb ========== */
.breadcrumb { padding: 1rem 0; font-size: .85rem; color: #8a7a6a; }
.breadcrumb a { color: #8a7a6a; }
.breadcrumb a:hover { color: #5a3e28; }
.breadcrumb .sep { margin: 0 .4rem; }

/* ========== Hero ========== */
.hero {
  text-align: center; padding: 3rem 0 2rem;
  background: linear-gradient(135deg, #f5f0e8 0%, #ebe3d6 100%);
  border-bottom: 1px solid #d9cdb8;
}
.hero .icon { font-size: 2.5rem; margin-bottom: .5rem; }
.hero h1 { font-size: 2rem; color: #3a2a1a; margin-bottom: .3rem; }
.hero .subtitle { font-size: 1rem; color: #7a6a5a; margin-bottom: .5rem; }
.hero .en-title { font-size: .95rem; color: #9a8a7a; font-style: italic; }
.hero .desc { max-width: 640px; margin: 1rem auto 0; color: #6a5a4a; font-size: .9rem; }
.hero .count { display: inline-block; margin-top: 1rem; padding: .3rem 1rem; background: #5a3e28; color: #fff; border-radius: 20px; font-size: .8rem; }

/* ========== Category Cards (index) ========== */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; padding: 2rem 0; }
.cat-card {
  background: #fff; border-radius: 12px; padding: 1.8rem;
  border: 1px solid #e8ddd0; transition: transform .2s, box-shadow .2s;
  display: flex; flex-direction: column;
}
.cat-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(90,62,40,.12); }
.cat-card .card-icon { font-size: 2rem; margin-bottom: .6rem; }
.cat-card h2 { font-size: 1.15rem; color: #3a2a1a; margin-bottom: .2rem; }
.cat-card .card-en { font-size: .82rem; color: #9a8a7a; margin-bottom: .8rem; }
.cat-card .card-desc { font-size: .85rem; color: #6a5a4a; flex: 1; margin-bottom: 1rem; }
.cat-card .card-count { font-size: .8rem; color: #8a7a6a; }
.cat-card .card-link { margin-top: auto; font-size: .85rem; color: #5a3e28; font-weight: 600; }

/* ========== Idiom List (category index) ========== */
.idiom-list { padding: 2rem 0; }
.idiom-list h2 { font-size: 1.4rem; color: #3a2a1a; margin-bottom: 1.5rem; border-bottom: 2px solid #d9cdb8; padding-bottom: .5rem; }
.idiom-item {
  display: flex; align-items: flex-start; gap: 1rem;
  padding: 1.2rem 0; border-bottom: 1px solid #ece5da;
  transition: background .15s;
}
.idiom-item:hover { background: #f8f4ee; }
.idiom-item:last-child { border-bottom: none; }
.idiom-item .num {
  flex-shrink: 0; width: 2rem; height: 2rem; border-radius: 50%;
  background: #5a3e28; color: #fff; display: flex; align-items: center;
  justify-content: center; font-size: .75rem; font-weight: 700; margin-top: .2rem;
}
.idiom-item .info { flex: 1; }
.idiom-item .info h3 { font-size: 1.1rem; color: #3a2a1a; margin-bottom: .1rem; }
.idiom-item .info .pinyin { font-size: .82rem; color: #9a8a7a; }
.idiom-item .info .en { font-size: .85rem; color: #7a6a5a; margin-top: .2rem; }
.idiom-item .info .source { font-size: .78rem; color: #a89a8a; margin-top: .3rem; }
.idiom-item .arrow { color: #c0b0a0; font-size: 1.2rem; align-self: center; }

/* ========== Detail Page ========== */
.detail-header {
  text-align: center; padding: 3rem 0 2rem;
  background: linear-gradient(135deg, #f5f0e8 0%, #ebe3d6 100%);
  border-bottom: 1px solid #d9cdb8;
}
.detail-header h1 { font-size: 2.2rem; color: #3a2a1a; margin-bottom: .3rem; }
.detail-header .pinyin { font-size: 1rem; color: #8a7a6a; letter-spacing: .1em; }
.detail-header .en-title { font-size: 1.05rem; color: #9a8a7a; font-style: italic; margin-top: .3rem; }
.detail-header .cat-badge {
  display: inline-block; margin-top: .8rem; padding: .25rem .8rem;
  background: #5a3e28; color: #fff; border-radius: 16px; font-size: .78rem;
}

.detail-body { padding: 2.5rem 0; }
.detail-body .section { margin-bottom: 2.5rem; }
.detail-body .section-title {
  font-size: 1.15rem; color: #5a3e28; margin-bottom: 1rem;
  padding-bottom: .4rem; border-bottom: 1px solid #e8ddd0;
  display: flex; align-items: center; gap: .5rem;
}
.detail-body .section-title .icon { font-size: 1.1rem; }

/* Original Text Block */
.original-text {
  background: #fdfbf8; border-left: 4px solid #5a3e28;
  padding: 1.5rem; margin: 1rem 0; border-radius: 0 8px 8px 0;
  font-size: 1.05rem; line-height: 2; color: #3a2a1a;
}
.original-text .source { display: block; margin-top: .8rem; font-size: .85rem; color: #8a7a6a; text-align: right; }

/* Annotation */
.annotation { font-size: .95rem; color: #4a3a2a; line-height: 2; }
.annotation p { margin-bottom: 1rem; text-indent: 2em; }
.annotation p:last-child { margin-bottom: 0; }

/* Modern Application */
.modern-app { font-size: .92rem; color: #5a4a3a; line-height: 1.9; }
.modern-app p { margin-bottom: 1rem; text-indent: 2em; }

/* Related Idioms */
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.related-card {
  background: #fdfbf8; border: 1px solid #e8ddd0; border-radius: 8px;
  padding: 1rem; text-align: center; transition: border-color .2s;
}
.related-card:hover { border-color: #5a3e28; }
.related-card .cn { font-size: 1.05rem; color: #3a2a1a; font-weight: 600; }
.related-card .en { font-size: .78rem; color: #8a7a6a; margin-top: .2rem; }

/* Further Reading */
.further-reading {
  display: flex; flex-wrap: wrap; gap: .6rem;
}
.further-reading a {
  display: inline-block; padding: .45rem 1rem;
  background: #fdfbf8; border: 1px solid #e8ddd0;
  border-radius: 20px; font-size: .85rem; color: #5a3e28;
  transition: all .2s;
}
.further-reading a:hover {
  background: #5a3e28; color: #fff; border-color: #5a3e28;
}

/* Prev/Next Nav */
.page-nav { display: flex; justify-content: space-between; gap: 1rem; padding: 2rem 0; border-top: 1px solid #e8ddd0; }
.page-nav a {
  flex: 1; padding: 1rem; background: #fff; border: 1px solid #e8ddd0;
  border-radius: 8px; transition: border-color .2s;
}
.page-nav a:hover { border-color: #5a3e28; }
.page-nav .label { font-size: .75rem; color: #8a7a6a; text-transform: uppercase; letter-spacing: .1em; }
.page-nav .title { font-size: .95rem; color: #3a2a1a; margin-top: .2rem; }
.page-nav .next { text-align: right; }

/* Search */
.nav-right { display: flex; align-items: center; gap: 1rem; flex: 1; justify-content: flex-end; }
.search-box { position: relative; }
.search-box input {
  padding: .35rem .8rem; border: 1px solid #5a4a3a; border-radius: 16px;
  background: #2a1e14; color: #e8ddd0; font-size: .8rem; width: 160px;
  outline: none; transition: width .2s, border-color .2s;
}
.search-box input::placeholder { color: #7a6a5a; }
.search-box input:focus { width: 220px; border-color: #c0a080; }
.search-results {
  display: none; position: absolute; top: 100%; right: 0; margin-top: .3rem;
  background: #fff; border: 1px solid #e8ddd0; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15); min-width: 280px; max-height: 360px;
  overflow-y: auto; z-index: 200;
}
.search-results a {
  display: block; padding: .6rem .8rem; color: #3a2a1a; font-size: .82rem;
  border-bottom: 1px solid #f0ebe4; transition: background .15s;
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: #f8f4ee; }
.search-results strong { color: #5a3e28; }
.search-results small { color: #8a7a6a; }
/* Source link */
.source a { color: #8b5e3c; text-decoration: underline; font-size: .82rem; }
.source a:hover { color: #5a3e28; }
/* Footer */
.site-footer {
  background: #2a1e14; color: #b0a090; padding: 3rem 0 0;
  margin-top: 3rem; font-size: .82rem;
}
.footer-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem; padding-bottom: 2.5rem;
}
.footer-col h4 {
  color: #e8ddd0; font-size: .88rem; margin-bottom: 1rem;
  padding-bottom: .4rem; border-bottom: 1px solid #3a2a1a;
  letter-spacing: .05em;
}
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: .5rem; }
.footer-col a { color: #9a8a7a; font-size: .8rem; transition: color .2s; }
.footer-col a:hover { color: #e8ddd0; }
.footer-col a .icon { margin-right: .3rem; }
.footer-bottom {
  border-top: 1px solid #3a2a1a; padding: 1.2rem 0;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .8rem; font-size: .75rem; color: #6a5a4a;
}
.footer-bottom a { color: #8a7a6a; }
.footer-bottom a:hover { color: #e8ddd0; }
.footer-bottom .footer-links { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.footer-quote { text-align: center; padding: 1.5rem 0; font-size: .78rem; color: #5a4a3a; font-style: italic; border-top: 1px solid #3a2a1a; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  html { font-size: 15px; }
  .hero h1, .detail-header h1 { font-size: 1.6rem; }
  .cat-grid { grid-template-columns: 1fr; }
  .idiom-item { flex-direction: column; gap: .5rem; }
  .idiom-item .num { width: 1.6rem; height: 1.6rem; font-size: .7rem; }
  .page-nav { flex-direction: column; }
  .nav-links { gap: .6rem; }
  .related-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-right { flex-wrap: wrap; }
  .search-box input { width: 120px; }
  .search-box input:focus { width: 160px; }
  .search-results { min-width: 240px; }
}
@media (max-width: 480px) {
  .container { padding: 0 1rem; }
  .hero { padding: 2rem 0 1.5rem; }
  .related-grid { grid-template-columns: 1fr; }
}

/* ========== Dark Mode (optional) ========== */
@media (prefers-color-scheme: dark) {
  body { background: #1a1612; color: #d4c5b0; }
  .hero, .detail-header { background: linear-gradient(135deg, #2a2018 0%, #221a12 100%); border-color: #3a2a1a; }
  .cat-card, .related-card, .page-nav a { background: #2a2018; border-color: #3a2a1a; }
  .idiom-item:hover { background: #2a2018; }
  .original-text { background: #221a12; border-color: #8b5e3c; }
  .site-nav { background: #1a1208; }
  .site-footer { background: #120e08; }
  h1, h2, h3, .cat-card h2, .idiom-item .info h3 { color: #e8ddd0; }
  .detail-body .section-title { color: #c0a080; border-color: #3a2a1a; }
}
