/* Base text: prefer TC (Traditional) first; fall back to SC and system CJK */
body {
  font-family:
    "Noto Serif TC", "Source Han Serif TC",
    "PingFang TC", "PMingLiU", "MingLiU",
    "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun",
    Georgia, "Times New Roman", serif;
  max-width: 720px;
  margin: auto;
  line-height: 1.75;            /* a touch looser for CJK readability */
  padding: 2rem;
  background: #fefefe;
  color: #333;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* If your HTML uses lang attributes, this ensures the right font set */
:lang(zh-Hant) {
  font-family:
    "Noto Serif TC", "Source Han Serif TC",
    "PingFang TC", "PMingLiU", "MingLiU",
    Georgia, serif;
  font-variant-east-asian: traditional;
}
:lang(zh-Hans) {
  font-family:
    "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun",
    Georgia, serif;
  font-variant-east-asian: simplified;
}

h1, h2, h3 { color: #003366; }

/* Lists & spacing */
ul, ol { padding-left: 1.5rem; }
li { margin-bottom: 0.5rem; }

/* Code blocks: pick a mono font with decent CJK fallback */
code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco,
               "JetBrains Mono", "Noto Sans Mono", monospace;
  background-color: #f5f5f5;
  padding: 2px 4px;
  border-radius: 3px;
}

/* Quotes */
blockquote {
  border-left: 4px solid #ccc;
  padding-left: 1em;
  color: #666;
}

/* Tables */
table {
  border-collapse: collapse;
  margin: 1em 0;
  width: 100%;
}
th, td {
  border: 1px solid #ccc;
  padding: 0.5em;
  text-align: left;
  background-color: #f9f9f9;
}
th { background-color: #e9ecef; }

/* Better line breaking for CJK text without smashing Latin words */
p, li, blockquote, td, th {
  word-break: keep-all;     /* don’t break Latin words */
  overflow-wrap: anywhere;  /* still wrap long CJK runs nicely */
}

