/* ---------- Design tokens ---------- */
:root {
  --red: #c8102e;
  --red-dark: #9b0c23;
  --gold: #d4a537;
  --ink: #1a1614;
  --muted: #6b625c;
  --bg: #fdf9f3;
  --card: #ffffff;
  --line: #ece4d8;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(40, 20, 10, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(920px, 92vw); margin: 0 auto; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(253, 249, 243, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 62px;
}
.brand {
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia, serif;
  font-weight: 700; font-size: 1.35rem;
  color: var(--red); text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.brand span { color: var(--ink); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 1.1rem; }
.nav { display: flex; gap: 22px; }
.nav a { color: var(--muted); text-decoration: none; font-size: 0.92rem; font-weight: 500; }
.nav a:hover { color: var(--red); }
@media (max-width: 620px) { .nav { display: none; } }

/* ---------- Hero ---------- */
.hero { padding: 64px 0 28px; text-align: center; }
.eyebrow {
  display: inline-block;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--gold);
  margin-bottom: 14px;
}
.hero h1 {
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia, serif;
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  line-height: 1.15; font-weight: 700;
}
.hero h1 .accent { color: var(--red); }
.hero .sub {
  max-width: 560px; margin: 18px auto 0;
  font-size: 1.08rem; color: var(--muted);
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Form ---------- */
.generator { padding: 20px 0 60px; }
.form-card { padding: 28px; display: grid; gap: 20px; }
.field { display: grid; gap: 8px; }
.label-text { font-size: 0.85rem; font-weight: 600; color: var(--muted); }

#name-input {
  width: 100%; padding: 14px 16px;
  font-size: 1.05rem;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink);
  transition: border-color .15s;
}
#name-input:focus { outline: none; border-color: var(--red); }

.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: #f3ece1; border-radius: 12px; padding: 4px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  text-align: center; padding: 10px 0; font-size: 0.92rem; font-weight: 500;
  border-radius: 9px; cursor: pointer; color: var(--muted);
  transition: all .15s;
}
.segmented input:checked + label {
  background: #fff; color: var(--red); font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.btn-primary {
  width: 100%; padding: 15px;
  font-size: 1.05rem; font-weight: 600;
  color: #fff; background: var(--red);
  border: none; border-radius: 12px; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn-primary:hover { background: var(--red-dark); }
.btn-primary:active { transform: translateY(1px); }

/* ---------- Result ---------- */
.result-card { padding: 32px 28px; margin-top: 22px; text-align: center; animation: pop .35s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.result-top { padding-bottom: 22px; border-bottom: 1px dashed var(--line); }
.hanzi {
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia, serif;
  font-size: clamp(3rem, 12vw, 5rem); font-weight: 700;
  color: var(--red); letter-spacing: 6px;
}
.pinyin { font-size: 1.3rem; color: var(--ink); margin-top: 6px; font-weight: 500; }

.breakdown { display: grid; gap: 12px; margin: 22px 0; text-align: left; }
.char-row {
  display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 14px;
  padding: 12px 14px; background: #fbf6ee; border-radius: 12px;
}
.char-row .c {
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia, serif; font-size: 2rem; font-weight: 700;
  color: var(--ink); width: 40px; text-align: center;
}
.char-row .p { font-weight: 600; color: var(--gold); min-width: 58px; }
.char-row .m { color: var(--muted); font-size: 0.95rem; }
.char-row .tag { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.blurb {
  background: #fff7ec; border: 1px solid #f0e2c8; border-radius: 12px;
  padding: 14px 16px; color: #7a5f2a; font-size: 0.96rem; margin-bottom: 22px;
}

.result-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn-ghost {
  padding: 10px 16px; font-size: 0.9rem; font-weight: 600;
  background: #fff; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer;
  transition: all .15s;
}
.btn-ghost:hover { border-color: var(--red); color: var(--red); }

/* ---------- Info sections ---------- */
.info { padding: 48px 0; border-top: 1px solid var(--line); }
.info h2 {
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia, serif; font-size: 1.7rem;
  text-align: center; margin-bottom: 30px;
}
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 700px) { .steps { grid-template-columns: 1fr; } }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--red); color: #fff; font-weight: 700; margin-bottom: 12px;
}
.step h3 { font-size: 1.05rem; margin-bottom: 6px; }
.step p { color: var(--muted); font-size: 0.94rem; }

/* ---------- FAQ ---------- */
.faq details {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px 18px; margin-bottom: 10px;
}
.faq summary {
  cursor: pointer; font-weight: 600; padding: 14px 0;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; float: right; color: var(--red); font-size: 1.3rem; line-height: 1; }
.faq details[open] summary::after { content: '−'; }
.faq details p { color: var(--muted); padding-bottom: 14px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 34px 0; text-align: center; }
.site-footer p { color: var(--ink); font-size: 0.95rem; }
.site-footer .muted { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.muted { color: var(--muted); }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 20px;
  border-radius: 999px; font-size: 0.9rem; z-index: 50;
  opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ============================================================
   MULTI-PAGE ADDITIONS (hub, tools, TTS, zodiac, numbers, phrases)
   ============================================================ */

/* active nav link */
.nav a.active { color: var(--red); }

/* ---------- Hub homepage ---------- */
.hub-hero { padding: 60px 0 30px; text-align: center; }
.hub-hero h1 { font-family: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia, serif; font-size: clamp(2rem, 5.5vw, 3rem); line-height: 1.15; }
.hub-hero h1 .accent { color: var(--red); }
.hub-hero .sub { max-width: 580px; margin: 16px auto 0; color: var(--muted); font-size: 1.08rem; }

.tool-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px;
  padding: 20px 0 60px;
}
@media (max-width: 640px) { .tool-grid { grid-template-columns: 1fr; } }
.tool-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
  transition: transform .12s, border-color .12s;
}
.tool-card:hover { transform: translateY(-3px); border-color: var(--red); }
.tool-card .ico { font-size: 2rem; margin-bottom: 12px; display: block; }
.tool-card h3 { font-size: 1.15rem; margin-bottom: 6px; }
.tool-card p { color: var(--muted); font-size: 0.94rem; }
.tool-card .go { color: var(--red); font-weight: 600; font-size: 0.9rem; margin-top: 10px; display: inline-block; }
.tool-card.soon { opacity: .6; }
.tool-card.soon:hover { transform: none; border-color: var(--line); }

/* ---------- Generic page header ---------- */
.page-head { padding: 46px 0 20px; text-align: center; }
.page-head h1 { font-family: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia, serif; font-size: clamp(1.8rem, 5vw, 2.6rem); }
.page-head h1 .accent { color: var(--red); }
.page-head .sub { max-width: 560px; margin: 12px auto 0; color: var(--muted); }
.section { padding: 10px 0 40px; }

/* ---------- Speak button ---------- */
.speak-btn {
  border: none; background: #fbf1e2; color: var(--red);
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  font-size: 1.05rem; flex: 0 0 auto; transition: background .12s, transform .12s;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; padding: 0; vertical-align: middle;
}
.speak-btn:hover { background: #f6e3c8; }
.speak-btn.speaking { animation: pulse .7s infinite; background: var(--red); color: #fff; }
@keyframes pulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.12);} }

/* ---------- Zodiac ---------- */
.zodiac-form { display: flex; gap: 10px; max-width: 420px; margin: 0 auto; }
.zodiac-form input {
  flex: 1; padding: 14px 16px; font-size: 1.05rem;
  border: 1.5px solid var(--line); border-radius: 12px;
}
.zodiac-form input:focus { outline: none; border-color: var(--red); }
.zodiac-result { text-align: center; padding: 34px 28px; margin-top: 24px; animation: pop .35s ease; }
.zodiac-emoji { font-size: 4.5rem; line-height: 1; }
.zodiac-name { font-family: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia, serif; font-size: 2.4rem; color: var(--red); margin-top: 8px; }
.zodiac-name .en { display:block; font-family:system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei",sans-serif; font-size: 1rem; color: var(--muted); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.zodiac-pinyin { font-size: 1.2rem; color: var(--gold); font-weight: 600; margin-top: 4px; }
.zodiac-traits { margin: 18px auto 0; max-width: 480px; color: var(--ink); }
.zodiac-years { margin-top: 14px; color: var(--muted); font-size: 0.9rem; }
.zodiac-strip { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin-top: 28px; }
.zodiac-chip { background:var(--card); border:1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 0.85rem; }
.zodiac-chip.hit { border-color: var(--red); color: var(--red); font-weight: 600; }

/* ---------- Numbers ---------- */
.num-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.num-cell {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; text-align: center; cursor: pointer; transition: border-color .12s;
}
.num-cell:hover { border-color: var(--red); }
.num-cell .arabic { font-size: 0.85rem; color: var(--muted); }
.num-cell .han { font-family:"Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia,serif; font-size: 1.9rem; color: var(--ink); margin: 2px 0; }
.num-cell .py { color: var(--gold); font-weight: 600; font-size: 0.92rem; }

.converter { max-width: 480px; margin: 0 auto 30px; padding: 24px; }
.converter input {
  width: 100%; padding: 14px 16px; font-size: 1.05rem;
  border: 1.5px solid var(--line); border-radius: 12px; margin-bottom: 14px;
}
.converter input:focus { outline: none; border-color: var(--red); }
.converter .out { text-align: center; min-height: 70px; }
.converter .out .han { font-family:"Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia,serif; font-size: 2rem; color: var(--red); }
.converter .out .py { color: var(--gold); font-weight: 600; margin-top: 4px; }
.converter .out.with-speak { display:flex; align-items:center; justify-content:center; gap: 14px; }

/* ---------- Phrases ---------- */
.phrase-cat { margin-bottom: 30px; }
.phrase-cat h2 { font-family:"Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia,serif; font-size: 1.4rem; margin-bottom: 14px; display:flex; align-items:center; gap: 10px; }
.phrase-list { display: grid; gap: 10px; }
.phrase-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px;
}
.phrase-row .txt { flex: 1; }
.phrase-row .han { font-family:"Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia,serif; font-size: 1.35rem; }
.phrase-row .py { color: var(--gold); font-weight: 600; font-size: 0.9rem; margin: 2px 0; }
.phrase-row .en { color: var(--muted); font-size: 0.92rem; }

/* small helper */
.note { text-align:center; color: var(--muted); font-size: 0.85rem; margin-top: 8px; }

/* ---------- Flashcards (HSK 1) ---------- */
.fc-bar { max-width: 460px; margin: 0 auto 22px; }
.fc-progress { height: 8px; background: #f0e7d9; border-radius: 999px; overflow: hidden; }
.fc-progress-fill { height: 100%; width: 0; background: var(--red); transition: width .3s; }
.fc-count { text-align: center; margin-top: 8px; font-size: 0.9rem; color: var(--muted); font-weight: 600; }

.flashcard { max-width: 460px; margin: 0 auto; perspective: 1200px; cursor: pointer; }
.fc-inner {
  position: relative; width: 100%; min-height: 260px;
  transition: transform .5s; transform-style: preserve-3d;
}
.fc-inner.flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
.fc-back { transform: rotateY(180deg); }
.fc-han { font-family:"Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia,serif; font-size: clamp(3rem, 14vw, 5rem); color: var(--ink); line-height: 1.1; }
.fc-front .speak-btn { margin-top: 16px; }
.fc-py { font-size: 1.6rem; color: var(--gold); font-weight: 700; }
.fc-en { font-size: 1.3rem; color: var(--ink); margin-top: 8px; }
.fc-cat { margin-top: 10px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background:#f5eee2; padding: 3px 10px; border-radius: 999px; }
.fc-hint { position: absolute; bottom: 12px; font-size: 0.75rem; color: #bcb2a6; }

.fc-controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.btn-ghost.is-known { border-color: var(--red); color: var(--red); background: #fdeef0; }

/* ---------- Pinyin page ---------- */
.pin-h2 { font-family:"Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia,serif; font-size: 1.5rem; margin: 34px 0 6px; }
.pin-h2 .pin-sub { font-family:system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei",sans-serif; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.pin-lead { color: var(--muted); margin-bottom: 16px; max-width: 620px; }

.tone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tone-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; cursor: pointer; transition: border-color .12s; display: flex; flex-direction: column; }
.tone-card:hover { border-color: var(--red); }
.tone-mark { font-size: 2.2rem; font-weight: 700; color: var(--red); }
.tone-name { font-weight: 600; font-size: 0.9rem; margin: 4px 0; }
.tone-desc { color: var(--muted); font-size: 0.86rem; flex: 1; }
.tone-ex { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.tex-char { font-family:"Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia,serif; font-size: 1.6rem; }
.tex-en { color: var(--muted); font-size: 0.85rem; flex: 1; }

.pin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.pin-cell { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; cursor: pointer; transition: border-color .12s; }
.pin-cell:hover { border-color: var(--red); }
.pin-sound { font-size: 1.4rem; font-weight: 700; color: var(--red); }
.pin-ex { font-family:"Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia,serif; font-size: 1.4rem; margin-top: 4px; }
.pin-ex .pin-py { font-family:system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei",sans-serif; font-size: 0.85rem; color: var(--gold); font-weight: 600; }
.pin-en { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

/* ---------- HSK1 static word list (SEO + reference) ---------- */
.wordlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.wl-item { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: baseline; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.wl-han { font-family:"Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia,serif; font-size: 1.25rem; }
.wl-py { color: var(--gold); font-weight: 600; font-size: 0.85rem; }
.wl-en { grid-column: 1 / -1; color: var(--muted); font-size: 0.85rem; margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--line); }
