:root{
  --bg0:#fbfbf8;
  --bg1:#f3f0e6;
  --paper: rgba(255,255,255,.72);
  --paper2: rgba(255,255,255,.82);
  --ink:#1e1b16;
  --muted:#5a544c;
  --line:#e7dfcf;

  --wan:#b10f2e;
  --tong:#0b7a75;
  --tiao:#2d7a34;
  --honor:#2b2b2b;

  --gold:#b88900;
  --gold2:#e0b43f;

  --shadow: 0 14px 35px rgba(20,16,10,.12);
  --shadow2: 0 10px 22px rgba(20,16,10,.10);
  --radius: 18px;
}

*{ box-sizing:border-box; }
html{ scroll-behavior:smooth; }
html,body{ height:100%; }

body{
  margin:0;
  color:var(--ink);
  background:
    radial-gradient(1200px 700px at 18% 8%, #ffffff 0%, rgba(255,255,255,0) 62%),
    radial-gradient(1000px 650px at 88% 16%, #fff2d7 0%, rgba(255,242,215,0) 60%),
    radial-gradient(900px 600px at 70% 88%, #e7f7f0 0%, rgba(231,247,240,0) 62%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  font-family: ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Heiti SC", sans-serif;
  line-height:1.55;
}

body::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  opacity:.55;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(30,27,22,.06) 1px, transparent 1.2px);
  background-size: 20px 20px;
  mix-blend-mode:multiply;
}

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

.wrap{
  max-width:1120px;
  margin:0 auto;
  padding:22px 18px 64px;
}

.icon{ width:18px; height:18px; flex:0 0 auto; }
.icon.big{ width:22px; height:22px; }

.kbd{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 8px;
  border:1px solid rgba(231,223,207,.95);
  background: rgba(255,255,255,.85);
  color: var(--muted);
}

header.hero{
  position:relative;
  border-radius: calc(var(--radius) + 10px);
  padding:26px 22px;
  overflow:hidden;
  background:
    linear-gradient(135deg, rgba(255,255,255,.9), rgba(255,255,255,.6)),
    radial-gradient(900px 600px at 20% 0%, rgba(177,15,46,.10), transparent 55%),
    radial-gradient(900px 600px at 90% 10%, rgba(11,122,117,.11), transparent 55%),
    radial-gradient(900px 600px at 70% 100%, rgba(45,122,52,.12), transparent 55%);
  box-shadow: var(--shadow);
  border:1px solid rgba(231,223,207,.8);
  backdrop-filter: blur(10px);
}

.hero-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:18px;
  flex-wrap:wrap;
}

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

.brand-mark{
  width:44px; height:44px;
  border-radius:14px;
  background: linear-gradient(135deg, #fff, #fff2d7);
  border:1px solid rgba(231,223,207,.9);
  box-shadow: var(--shadow2);
  display:grid; place-items:center;
}

.brand h1{
  margin:0;
  font-family: ui-serif, "Songti SC", "STSong", "SimSun", serif;
  font-size: 26px;
  letter-spacing:.4px;
  line-height:1.1;
}

.brand p{
  margin:6px 0 0;
  color:var(--muted);
  max-width:70ch;
}

.hero-actions{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

.btn{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius: 14px;
  border:1px solid rgba(231,223,207,.95);
  background: rgba(255,255,255,.75);
  box-shadow: var(--shadow2);
  cursor:pointer;
  user-select:none;
  transition: transform .14s ease, background .14s ease;
}

.btn:hover{ transform: translateY(-1px); background: rgba(255,255,255,.92); }
.btn.primary{
  border-color: rgba(184,137,0,.35);
  background: linear-gradient(135deg, rgba(255,249,230,.95), rgba(255,255,255,.75));
}
.btn .k{ font-weight:700; }
.btn small{ color:var(--muted); }

.progress{
  margin-top:14px;
  border-radius: 16px;
  border:1px solid rgba(231,223,207,.85);
  background: rgba(255,255,255,.72);
  box-shadow: var(--shadow2);
  backdrop-filter: blur(10px);
  overflow:hidden;
}

.progress-rail{
  height: 10px;
  background: rgba(30,27,22,.06);
  border-bottom: 1px solid rgba(231,223,207,.85);
}

.progress-fill{
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(184,137,0,.65), rgba(224,180,63,.92));
  transition: width .12s linear;
}

.progress-meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 10px 12px;
  flex-wrap:wrap;
}

.progress-text{
  color: var(--muted);
  font-size: 13px;
}

nav.sticky{
  position:sticky;
  top:10px;
  z-index:10;
  margin:16px 0 0;
  padding:10px 10px;
  border-radius: 16px;
  background: rgba(255,255,255,.72);
  border:1px solid rgba(231,223,207,.85);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow2);
}

.nav-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
}

.chips{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
}

.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:7px 10px;
  border-radius: 999px;
  border:1px solid rgba(231,223,207,.95);
  background: rgba(255,255,255,.75);
  transition: background .12s ease, transform .12s ease;
  font-size: 13px;
  color: var(--muted);
}

.chip:hover{ background: rgba(255,255,255,.95); transform: translateY(-1px); }

.chip.is-active,
.chip[aria-current="page"]{
  color: var(--ink);
  border-color: rgba(184,137,0,.35);
  background: linear-gradient(135deg, rgba(255,249,230,.95), rgba(255,255,255,.75));
}

.tag{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:7px 10px;
  border-radius: 999px;
  border:1px solid rgba(231,223,207,.95);
  background: rgba(255,255,255,.75);
  color: var(--muted);
  font-size: 13px;
}

main{ margin-top: 16px; }

section.card{
  margin-top: 16px;
  border-radius: var(--radius);
  border:1px solid rgba(231,223,207,.85);
  background: var(--paper);
  box-shadow: var(--shadow2);
  overflow:hidden;
  backdrop-filter: blur(10px);
  transform: translateY(10px);
  opacity:0;
  transition: transform .45s ease, opacity .45s ease;
}

section.card.is-visible{
  transform: translateY(0);
  opacity:1;
}

.card-h{
  display:flex;
  gap:12px;
  align-items:flex-start;
  justify-content:space-between;
  padding:18px 18px 0;
  flex-wrap:wrap;
}

.card-h h2{
  margin:0;
  font-family: ui-serif, "Songti SC", "STSong", "SimSun", serif;
  font-size: 20px;
  letter-spacing:.2px;
}

.subtitle{
  margin:8px 0 0;
  color:var(--muted);
  max-width: 84ch;
}

.card-b{ padding: 16px 18px 18px; }

.grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

.col-12{ grid-column: span 12; }
.col-8{ grid-column: span 8; }
.col-6{ grid-column: span 6; }
.col-4{ grid-column: span 4; }
.col-3{ grid-column: span 3; }

@media (max-width: 900px){
  .col-8,.col-6,.col-4,.col-3{ grid-column: span 12; }
}

.panel{
  border-radius: 16px;
  border:1px solid rgba(231,223,207,.85);
  background: rgba(255,255,255,.75);
  padding: 14px 14px;
}

.panel h3{
  margin:0;
  font-size: 15px;
  letter-spacing:.2px;
}

.panel p{ margin:8px 0 0; color:var(--muted); }

.callout{
  display:flex;
  gap:12px;
  align-items:flex-start;
  padding: 12px 12px;
  border-radius: 16px;
  border:1px solid rgba(184,137,0,.28);
  background: linear-gradient(135deg, rgba(255,249,230,.92), rgba(255,255,255,.75));
}

.callout .title{ font-weight:700; }
.callout .text{ color:var(--muted); margin-top:3px; }

.tiles-line{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
}

.sep{
  width:10px;
  height:24px;
  border-radius:999px;
  background: linear-gradient(180deg, rgba(30,27,22,.12), rgba(30,27,22,.05));
  border: 1px solid rgba(30,27,22,.10);
  margin: 0 2px;
}

.tile{
  width: 46px;
  height: 62px;
  border-radius: 14px;
  border: 1px solid rgba(231,223,207,.95);
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,255,255,.76));
  box-shadow: 0 10px 18px rgba(20,16,10,.10);
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  padding:7px 8px 6px;
  position:relative;
  overflow:hidden;
}

.tile::after{
  content:"";
  position:absolute;
  inset:-30% -30%;
  background: radial-gradient(closest-side, rgba(0,0,0,.10), transparent 70%);
  transform: translate(38%, -28%) rotate(12deg);
  opacity:.14;
}

.tile .n{
  font-weight:800;
  font-size: 16px;
  line-height:1;
  z-index:1;
}

.tile .s{
  z-index:1;
  display:flex;
  align-items:center;
  gap:6px;
  font-size: 14px;
  font-weight:700;
}

.tile .s svg{ width:16px; height:16px; }

.tile.wan .n, .tile.wan .s{ color: var(--wan); }
.tile.tong .n, .tile.tong .s{ color: var(--tong); }
.tile.tiao .n, .tile.tiao .s{ color: var(--tiao); }
.tile.honor .n, .tile.honor .s{ color: var(--honor); }
.tile.honor .n{ font-size: 15px; }

.tile.mini{
  width: 40px;
  height: 54px;
  padding:6px 7px;
  border-radius: 13px;
}

.flow{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 10px;
  align-items:stretch;
}

.flow .box{
  grid-column: span 3;
  border-radius: 16px;
  border:1px solid rgba(231,223,207,.85);
  background: rgba(255,255,255,.78);
  padding: 12px 12px;
  min-height: 88px;
}

.flow .box h4{
  margin:0;
  font-size: 14px;
  display:flex;
  align-items:center;
  gap:8px;
}

.flow .box p{ margin:8px 0 0; color:var(--muted); font-size: 13px; }

.flow .arrow{
  grid-column: span 1;
  display:flex;
  align-items:center;
  justify-content:center;
  color: rgba(30,27,22,.35);
}

@media (max-width: 900px){
  .flow .box{ grid-column: span 12; }
  .flow .arrow{ display:none; }
}

.ladder{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:stretch;
}

.pill{
  flex: 1 1 160px;
  border-radius: 16px;
  border:1px solid rgba(231,223,207,.85);
  background: rgba(255,255,255,.78);
  padding: 12px 12px;
  display:flex;
  gap:10px;
  align-items:flex-start;
}

.pill strong{ display:block; }
.pill small{ color: var(--muted); }

details{
  border-radius: 16px;
  border:1px solid rgba(231,223,207,.85);
  background: rgba(255,255,255,.72);
  padding: 10px 12px;
}

details summary{
  cursor:pointer;
  list-style:none;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  user-select:none;
}

details summary::-webkit-details-marker{ display:none; }

details .d-b{ margin-top: 10px; color: var(--muted); }

.chev{
  width: 18px; height: 18px;
  opacity:.6;
  transition: transform .2s ease;
}

details[open] .chev{ transform: rotate(180deg); }

.chapter-grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.chapter-card{
  grid-column: span 6;
  border-radius: 18px;
  border:1px solid rgba(231,223,207,.85);
  background: rgba(255,255,255,.72);
  box-shadow: var(--shadow2);
  padding: 14px 14px;
  display:flex;
  gap:12px;
  align-items:flex-start;
  transition: transform .14s ease, background .14s ease;
}

.chapter-card:hover{ transform: translateY(-1px); background: rgba(255,255,255,.92); }

.chapter-card h3{
  margin:0;
  font-size: 16px;
  letter-spacing:.2px;
}

.chapter-card p{
  margin:6px 0 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 70ch;
}

.chapter-card .meta{
  margin-top:10px;
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 900px){
  .chapter-card{ grid-column: span 12; }
}

.pager{
  margin-top: 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}

.site-footer{
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align:center;
}

/* Quiz */
.quiz{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

.q{
  grid-column: span 4;
  border-radius: 16px;
  border:1px solid rgba(231,223,207,.85);
  background: rgba(255,255,255,.78);
  padding: 12px 12px;
  cursor:pointer;
  transition: transform .14s ease, background .14s ease;
}

.q:hover{ transform: translateY(-1px); background: rgba(255,255,255,.92); }

.q h4{
  margin:0;
  font-size: 14px;
  display:flex;
  align-items:center;
  gap:8px;
}

.q .hint{
  margin-top:8px;
  color:var(--muted);
  font-size: 13px;
}

.q .ans{
  margin-top: 10px;
  display:none;
  padding: 10px 10px;
  border-radius: 14px;
  border:1px solid rgba(184,137,0,.25);
  background: linear-gradient(135deg, rgba(255,249,230,.95), rgba(255,255,255,.78));
  color: var(--muted);
  font-size: 13px;
}

.q.revealed .ans{ display:block; }

@media (max-width: 900px){
  .q{ grid-column: span 12; }
}

@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; scroll-behavior:auto !important; }
}

@media print{
  body{ background:white; }
  body::before, nav.sticky{ display:none !important; }
  header.hero, section.card, .chapter-card{ box-shadow:none; background:white; border-color:#ddd; }
  .btn{ display:none !important; }
}