/* Quiet reading room: neutral paper, dark jade/ink and pale jade accents. Local fonts only. */
:root {
  --paper: #f4f1e8;
  --paper-2: #ebe7da;
  --card: #fbf9f3;
  --ink: #23312f;
  --ink-soft: #4d5c58;
  --line: #c6d5cd;
  --teal: #2f5d5a;
  --teal-deep: #1f4240;
  --clay: #24534a;
  --gold: #d5e7de;
  --warn-bg: #e7f0eb;
  --serif: "Songti SC", "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif SC", "Songti TC", "Noto Serif CJK TC", Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: "PingFang SC", "PingFang TC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Hiragino Sans GB", system-ui, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Noto Sans Mono CJK SC", monospace;
  --measure: 40rem;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 1.0625rem/1.8 var(--serif); overflow-wrap: anywhere;
}
:lang(zh-hans), :lang(zh-hant) { line-height: 1.95; letter-spacing: .02em; }
a { color: var(--teal); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--clay); }
:focus-visible { outline: 3px solid var(--clay); outline-offset: 3px; border-radius: 2px; }
.skip-link { position: absolute; left: .5rem; top: -4rem; background: var(--teal-deep); color: #fff; padding: .7rem 1rem; z-index: 20; font-family: var(--sans); transition: top .15s; }
.skip-link:focus { top: .5rem; color: #fff; }
main:focus { outline: none; }

/* Header */
.site-header { background: var(--teal-deep); color: #eef0e6; font-family: var(--sans); }
.header-inner { max-width: 70rem; margin: 0 auto; padding: .9rem 1.25rem; display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; justify-content: space-between; }
.brand { display: flex; gap: .75rem; align-items: center; color: #fff; text-decoration: none; }
.brand:hover { color: var(--gold); }
.brand-mark { width: 2.1rem; height: 2.1rem; border-radius: 50%; border: 2px solid var(--gold); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 6px 4px 6px 12px; background: var(--gold); border-radius: 0 50% 50% 0; }
.brand-text { display: grid; line-height: 1.3; }
.brand-text strong { font-size: 1.05rem; }
.brand-text small { color: #bccbc4; font-size: .8rem; }
ul { margin: 0; padding: 0; list-style: none; }
.lang-list { display: flex; gap: .25rem; }
.lang-list a { display: inline-block; padding: .45rem .8rem; min-height: 2.5rem; color: #dbe5df; text-decoration: none; border: 1px solid #4d716d; border-radius: 999px; font-size: .9rem; }
.lang-list a:hover { background: #2c5552; color: #fff; }
.lang-list a[aria-current] { background: var(--gold); color: var(--teal-deep); border-color: var(--gold); font-weight: 600; }
.site-nav { background: var(--paper-2); border-bottom: 1px solid var(--line); }
.site-nav ul { max-width: 70rem; margin: 0 auto; padding: 0 .75rem; display: flex; flex-wrap: wrap; }
.site-nav a { display: block; padding: .75rem .9rem; min-height: 2.75rem; color: var(--ink); text-decoration: none; font-family: var(--sans); font-size: .95rem; border-bottom: 3px solid transparent; }
.site-nav a:hover { color: var(--teal); background: #dfeae3; }
.site-nav a[aria-current] { border-bottom-color: var(--clay); font-weight: 600; }
.site-header:focus-within { position: relative; }

/* Main */
.site-main { max-width: 70rem; margin: 0 auto; padding: 2rem 1.25rem 4rem; animation: fade .4s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
h1, h2, h3, h4 { line-height: 1.3; font-weight: 700; color: var(--teal-deep); text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 5vw, 3rem); margin: 0 0 1rem; }
h2 { font-size: clamp(1.4rem, 3vw, 1.85rem); margin: 2.5rem 0 .75rem; }
h3 { font-size: 1.2rem; margin: 1.75rem 0 .5rem; }
p { margin: 0 0 1.1em; }

.eyebrow { font: 600 .8rem/1.4 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--clay); margin: 0 0 .6rem; }
:lang(zh-hans) .eyebrow, :lang(zh-hant) .eyebrow { letter-spacing: .2em; }
.lede { font-size: 1.25rem; color: var(--ink-soft); max-width: 44rem; }

.home-hero { padding: 2.5rem 1.5rem; margin: 0 -.25rem 2.5rem; background: linear-gradient(135deg, var(--paper-2), var(--gold) 220%); border: 1px solid var(--line); border-left: 8px solid var(--teal); border-radius: 4px; }
.home-hero h1 { max-width: 20ch; }
.home-hero .actions { margin-top: 1.5rem; }

/* Reading path */
.reading-path { counter-reset: none; display: grid; gap: 1rem; margin: 1.5rem 0 3rem; padding: 0; list-style: none; position: relative; }
.guide-card { position: relative; display: grid; grid-template-columns: auto 1fr; gap: .25rem 1.1rem; padding: 1.25rem; background: var(--card); border: 1px solid var(--line); border-radius: 4px; transition: border-color .2s, transform .2s; }
.guide-card:hover, .guide-card:focus-within { border-color: var(--teal); transform: translateY(-2px); }
.guide-card h2, .guide-card h3 { margin: 0 0 .3rem; font-size: 1.2rem; }
.guide-card p { margin: 0; color: var(--ink-soft); font-size: .98rem; }
.guide-card > :not(.step-number) { grid-column: 2; }
.step-number { grid-row: 1 / span 3; width: 2.6rem; height: 2.6rem; display: grid; place-items: center; border-radius: 50%; background: var(--teal); color: #fff; font: 700 1.1rem var(--sans); }
@media (min-width: 48rem) { .reading-path { grid-template-columns: repeat(2, 1fr); } .reading-path .guide-card:first-child { grid-column: 1 / -1; background: var(--paper-2); } }

/* Article */
.article { max-width: 48rem; margin: 0 auto; }
.article-header { padding-bottom: 1.25rem; margin-bottom: 1.75rem; border-bottom: 2px solid var(--line); }
.reader-context { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--gold); padding: 1rem 1.25rem; margin: 1.25rem 0; font-family: var(--sans); font-size: .95rem; color: var(--ink-soft); border-radius: 3px; }
.reader-context > :last-child { margin-bottom: 0; }
.prose { max-width: var(--measure); }
.article .prose { max-width: none; }
.prose img { display: block; max-width: 100%; height: auto; margin: 1.5rem auto; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.2em; }
.prose ul { list-style: disc; }
.prose li { margin-bottom: .4em; padding-left: .2em; }
.prose li::marker { color: var(--clay); }
.prose blockquote { margin: 1.5rem 0; padding: .25rem 1.25rem; border-left: 4px solid var(--teal); background: var(--paper-2); color: var(--ink-soft); }
.prose strong { color: var(--teal-deep); }
.prose code, pre { font-family: var(--mono); font-size: .92em; }
.prose code { background: var(--paper-2); padding: .1em .35em; border-radius: 3px; }
.next-action { margin: 2.5rem 0 1rem; padding: 1.5rem; background: var(--teal-deep); color: #eef0e6; border-radius: 4px; }
.next-action h2, .next-action h3 { color: #fff; margin-top: 0; }
.next-action a:not(.button) { color: var(--gold); }
.guide-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; margin: 2rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--line); font-family: var(--sans); }
.guide-nav a { display: inline-block; padding: .6rem 0; min-height: 2.75rem; }

.resource-intro { max-width: 46rem; margin-bottom: 2rem; }
.notice { padding: 1rem 1.25rem; margin: 1.5rem 0; background: var(--warn-bg); border: 1px solid #78978a; border-left: 6px solid var(--clay); border-radius: 3px; font-family: var(--sans); font-size: .98rem; }
.notice > :last-child { margin-bottom: 0; }
.example { margin: 1.5rem 0; padding: 1.1rem 1.25rem; background: var(--card); border: 1px dashed var(--teal); border-radius: 4px; }
.example > :first-child { margin-top: 0; }
.example > :last-child { margin-bottom: 0; }

/* Worksheet */
.notes-grid { display: grid; gap: 1.25rem; margin: 1.5rem 0; }
@media (min-width: 52rem) { .notes-grid { grid-template-columns: 1fr 1fr; } }
.note-field { display: grid; gap: .4rem; align-content: start; padding: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 4px; }
.note-field label, .note-field > span, .note-field legend { font: 600 1rem/1.5 var(--sans); color: var(--teal-deep); }
.note-field small, .note-field p { color: var(--ink-soft); font: .88rem/1.6 var(--sans); margin: 0; }
textarea, input[type=text], input[type=search], input:not([type]), select {
  width: 100%; font: 1rem/1.7 var(--serif); color: var(--ink); background: #fffdf7; border: 1px solid #718d80; border-radius: 3px; padding: .7rem .8rem;
}
textarea { min-height: 9rem; resize: vertical; }
textarea:focus, input:focus { border-color: var(--teal); outline: 3px solid #24534a; outline-offset: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.5rem 0; align-items: center; }
.button, button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.9rem; padding: .6rem 1.3rem; font: 600 1rem var(--sans); color: #fff; background: var(--teal); border: 2px solid var(--teal); border-radius: 3px; cursor: pointer; text-decoration: none; transition: background-color .2s, color .2s, border-color .2s; }
.button:hover, button:hover { background: var(--teal-deep); border-color: var(--teal-deep); color: #fff; }
.button.secondary, button.secondary { background: transparent; color: var(--teal-deep); border-color: var(--teal); }
.button.secondary:hover, button.secondary:hover { background: var(--paper-2); color: var(--teal-deep); }
.button.danger, button.danger { background: transparent; color: #23312f; border-color: #23312f; }
.button.danger:hover, button.danger:hover { background: #23312f; color: #fff; }
.next-action .button.secondary { color: #fff; border-color: var(--gold); }
.next-action .button.secondary:hover { background: #2c5552; color: #fff; }
.header-inner :focus-visible, .next-action :focus-visible { outline-color: var(--gold); }
button[disabled] { opacity: .55; cursor: not-allowed; }
[role=status], .status { font-family: var(--sans); font-size: .92rem; color: var(--ink-soft); min-height: 1.5em; }
.print-only { display: none; }
[hidden] { display: none !important; }
dd { margin: .25rem 0 1rem 1rem; }
pre.print-answer { overflow-wrap: anywhere; }
pre.print-answer { white-space: pre-wrap; font-family: var(--serif); font-size: 1rem; margin: 0; }

/* References */
.reference-grid { display: grid; gap: 1rem; margin: 1.5rem 0; }
@media (min-width: 48rem) { .reference-grid { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); } }
.reference-grid > * { padding: 1rem 1.25rem; background: var(--card); border: 1px solid var(--line); border-radius: 4px; }
.source-list { margin: 1.5rem 0; padding: 0; list-style: none; display: grid; gap: .9rem; }
.source-list li { padding: .9rem 1.1rem; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: 3px; font-family: var(--sans); font-size: .95rem; }
.table-wrap, .prose .table-scroll, .source-table { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; margin: 1.5rem 0; }
table { border-collapse: collapse; width: 100%; min-width: 34rem; font: .93rem/1.6 var(--sans); background: var(--card); }
:is(.prose, .article, .resource-intro, main) > table { display: block; overflow-x: auto; max-width: 100%; }
th, td { padding: .65rem .8rem; border: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--paper-2); color: var(--teal-deep); }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

/* Footer */
.site-footer { background: var(--paper-2); border-top: 1px solid var(--line); font: .92rem/1.8 var(--sans); color: var(--ink-soft); }
.footer-inner { max-width: 70rem; margin: 0 auto; padding: 2rem 1.25rem; }
.footer-inner p { max-width: 46rem; margin: 0 0 .6rem; }
.footer-brand { font-weight: 700; color: var(--teal-deep); }
.updated { font-size: .82rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.footer-links a { display: inline-block; padding: .6rem 0; }

@media (max-width: 40rem) {
  body { font-size: 1.03rem; }
  .home-hero { padding: 1.75rem 1.1rem; }
  .actions > .button, .actions > button { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .guide-card:hover { transform: none; }
}
@media (prefers-contrast: more) { :root { --line: #637c70; --ink-soft: #2f3c39; } }

.print-section-start, .print-definition { display: contents; }
@media print {
  .print-section-start, .print-comparison { display: block; page-break-inside: avoid; break-inside: avoid; }
  .print-definition { display: block; page-break-inside: avoid; break-inside: avoid; }
  .reading-path, .guide-card { display: block; }
  .print-first-content { margin-bottom: 0; }
  .example { page-break-inside: auto; break-inside: auto !important; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; break-inside: avoid; }
  :root { --paper: #fff; }
  body { background: #fff; color: #000; font-size: 11.5pt; line-height: 1.6; }
  .no-print, .site-header, .actions, button, .skip-link, .guide-nav, .site-nav { display: none !important; }
  .print-only { display: block !important; }
  .site-main { max-width: none; padding: 0; animation: none; }
  .site-footer { background: none; border-top: 1px solid #000; color: #000; }
  .home-hero, .guide-card, .example, .notice, .reader-context, .source-list li, .reference-grid > * { background: none; border-color: #555; break-inside: avoid; }
  /* Block fragmentation is more reliable than grid fragmentation in WebKit.
     Avoid is a preference, not a fixed height: oversized answers may split. */
  .note-field { display: block; background: none; border-color: #555; page-break-inside: avoid; break-inside: avoid; }
  .note-field label { display: block; }
  .note-field label, .note-field > p { page-break-after: avoid; break-after: avoid; }
  .source-list { display: block; }
  .source-list li { margin-bottom: .9rem; page-break-inside: avoid; break-inside: avoid; }
  .site-footer, .footer-inner { page-break-inside: avoid; break-inside: avoid; }
  p, pre.print-answer { orphans: 3; widows: 3; }
  .next-action { background: none; color: #000; border: 1px solid #555; }
  .next-action h2, .next-action h3, .next-action a { color: #000 !important; }
  textarea { display: none !important; }
  .notes-grid { display: block; }
  .note-field { margin-bottom: 1rem; }
  pre.print-answer { display: block !important; white-space: pre-wrap; border-top: 1px solid #555; padding-top: .5rem; min-height: 3rem; max-height: none; overflow: visible; page-break-inside: auto; break-inside: auto; }
  .table-wrap, .source-table, :is(.prose, .article, .resource-intro, main) > table { overflow: visible; display: block; }
  table { min-width: 0; font-size: 9.5pt; }
  a { color: #000; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; overflow-wrap: anywhere; }
  h1, h2, h3 { color: #000; page-break-after: avoid; break-after: avoid; }
}
