/* 註解 Annotated — black / white + brand red. No external fonts, no build step.
   The brand color lives ONLY in --accent; change it there. */
:root {
  --ink: #111111;
  --paper: #ffffff;
  --muted: #4a4a4a;      /* 8.9:1 on white */
  --rule: #d9d9d9;
  --tint: #f5f5f5;
  --accent: #b72b35;     /* brand red (owner palette) */
  --accent-soft: #f0908d; /* salmon // on black (dark brand variants) */
  --accent-ink: #ffffff; /* text on vermilion */
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Noto Sans Mono CJK TC", monospace;
  --wrap: 64rem;
  --gutter: 16px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

a { color: var(--ink); text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

code, pre, kbd { font-family: var(--mono); font-size: 0.92em; font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; } /* show == and != literally */
code { background: var(--tint); padding: 0.1em 0.35em; border-radius: 3px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.narrow { max-width: 46rem; }

.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: var(--gutter); }

/* Header */
.site-header { border-bottom: 1px solid var(--ink); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding-top: 0.875rem; padding-bottom: 0.875rem; }
.brand { font-family: var(--mono); font-weight: 700; font-size: 1.05rem; text-decoration: none; letter-spacing: 0.01em; white-space: nowrap; }
.brand .slashes, .mark { color: var(--accent); }
.brand .brand-latin { color: var(--muted); font-weight: 600; }
.brand-mark { display: block; height: 2rem; width: auto; }
.site-nav a[aria-current="page"] { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent); }
.site-nav ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; list-style: none; margin: 0; padding: 0; font-size: 0.95rem; }
.site-nav a { text-decoration: none; }
.site-nav a:hover { text-decoration: underline; text-decoration-color: var(--accent); }

/* Sections */
main { display: block; }
section { padding: 3.5rem 0; border-bottom: 1px solid var(--rule); }
section:last-of-type { border-bottom: 0; }
h1, h2, h3 { line-height: 1.3; font-weight: 800; margin: 0 0 1rem; }
h2 { font-size: clamp(1.5rem, 4.5vw, 2rem); }
h2::before { content: "// "; font-family: var(--mono); color: var(--accent); font-weight: 700; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1rem; }
.lead { font-size: 1.15rem; color: var(--muted); }
.muted { color: var(--muted); }

/* Hero */
.hero { padding: 4.5rem 0 3.5rem; border-bottom: 1px solid var(--ink); }
.hero h1 { font-size: clamp(2.25rem, 10vw, 4.25rem); letter-spacing: 0.02em; margin-bottom: 1.25rem; }
.hero .eyebrow { font-family: var(--mono); color: var(--accent); font-weight: 700; margin-bottom: 0.75rem; }
.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; margin: 1.25rem 0 2rem; }
.tags li { font-family: var(--mono); font-size: 0.9rem; border: 1px solid var(--ink); padding: 0.15rem 0.6rem; }

.code-sample { background: var(--ink); color: #f2f2f2; padding: 1rem 1.125rem; margin: 2rem 0 0; overflow-x: auto; line-height: 1.6; font-size: 0.9rem; border-left: 4px solid var(--accent); }
.code-sample code { background: none; padding: 0; font-size: inherit; color: inherit; }
.code-sample .c { color: var(--accent-soft); } /* comment: 6.9:1 on #111 */

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.btn { display: inline-block; padding: 0.7rem 1.25rem; border: 2px solid var(--ink); text-decoration: none; font-weight: 700; line-height: 1.3; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn:not(.btn-primary):hover { background: var(--ink); color: var(--paper); }

/* Grids */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); list-style: none; padding: 0; margin: 0; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
.card { border: 1px solid var(--ink); padding: 1.25rem; background: var(--paper); }
.card h3 { margin-bottom: 0.5rem; }
.card p:last-child { margin-bottom: 0; }
.card .num { font-family: var(--mono); color: var(--accent); font-weight: 700; display: block; margin-bottom: 0.25rem; }
.status { font-family: var(--mono); font-size: 0.8rem; border: 1px solid var(--muted); color: var(--muted); padding: 0 0.4rem; margin-left: 0.4rem; vertical-align: 0.15em; white-space: nowrap; }

.callout { border-left: 4px solid var(--accent); background: var(--tint); padding: 1rem 1.125rem; margin: 1.5rem 0 0; }
.callout p:last-child { margin-bottom: 0; }

/* FAQ */
.faq details { border-top: 1px solid var(--rule); padding: 0.25rem 0; }
.faq details:last-child { border-bottom: 1px solid var(--rule); }
.faq summary { cursor: pointer; font-weight: 700; padding: 0.75rem 0; list-style-position: outside; }
.faq summary::marker { color: var(--accent); }
.faq .answer { padding: 0 0 0.75rem; }
.faq-note { margin-top: 1rem; }
.ch { font-family: var(--mono); white-space: nowrap; }

/* Legal pages */
.draft-banner { background: var(--accent); color: var(--accent-ink); padding: 0.75rem var(--gutter); margin: 0; text-align: center; font-weight: 700; }
.legal { padding: 2.5rem 0 3.5rem; }
.legal h1 { font-size: clamp(1.5rem, 6vw, 2.25rem); }
.legal h2 { font-size: 1.25rem; margin-top: 2.25rem; }
.legal h2::before { content: none; }
.legal blockquote { margin: 1.5rem 0; padding: 0.75rem 1rem; border-left: 4px solid var(--accent); background: var(--tint); }
.legal blockquote p:last-child { margin-bottom: 0; }
.legal ul, .legal ol { padding-left: 1.5rem; }
.legal table { border-collapse: collapse; width: 100%; font-size: 0.95rem; display: block; overflow-x: auto; }
.legal th, .legal td { border: 1px solid var(--rule); padding: 0.5rem 0.625rem; text-align: left; vertical-align: top; }
.legal th { background: var(--tint); }

/* 404 */
.notfound { padding: 5rem 0; }
.notfound .code { font-family: var(--mono); font-size: clamp(3rem, 18vw, 6rem); font-weight: 700; line-height: 1; margin: 0 0 1rem; }

/* Inner pages */
.page-head { padding: 3rem 0 2.5rem; border-bottom: 1px solid var(--ink); }
.page-head h1 { font-size: clamp(1.9rem, 7vw, 3rem); }
.eyebrow { font-family: var(--mono); color: var(--accent); font-weight: 700; margin-bottom: 0.5rem; }
.eyebrow a { color: inherit; text-decoration: none; }
.toc { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; list-style: none; padding: 0; margin: 1.5rem 0 0; font-size: 0.95rem; }
.toc a::before { content: "# "; font-family: var(--mono); color: var(--accent); }
.narrow-text { max-width: 46rem; }
.small { font-size: 0.9rem; }
.nowrap { white-space: nowrap; }
.links-row { margin-top: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.grid + p, .grid + h3, .table-wrap + p { margin-top: 1rem; }
ul.compact { padding-left: 1.2rem; margin: 0.25rem 0 0; }
ul.compact li { margin: 0.1rem 0; }
.facts li { margin-bottom: 0.4rem; }
h3 { margin-top: 1.75rem; }
.card h3, .page-head h3 { margin-top: 0; }
.tags a { text-decoration: none; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 1rem 0; }
.table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.table th, .table td { border: 1px solid var(--rule); padding: 0.5rem 0.625rem; text-align: left; vertical-align: top; }
.table th { background: var(--tint); white-space: nowrap; }

/* Pills, placeholders */
.pill { display: inline-block; font-family: var(--mono); font-size: 0.75rem; line-height: 1.5; border: 1px solid var(--muted); color: var(--muted); padding: 0 0.4rem; white-space: nowrap; vertical-align: 0.1em; }
.pill-ok { border-color: var(--ink); color: var(--ink); }
.pill-warn { border-style: dashed; }
.pill-est { border-color: var(--accent); color: var(--accent); }
.placeholder { border: 2px dashed var(--accent); padding: 0.75rem 1rem; }

/* Roadmap */
.topic-tree { list-style: none; padding-left: 0; margin: 0.5rem 0 1rem; }
.topic-tree .topic-tree { padding-left: 1.1rem; border-left: 2px solid var(--rule); margin: 0.35rem 0 0.5rem 0.3rem; }
.topic-tree li { margin: 0.35rem 0; }
.topic-tree li:target { background: var(--tint); outline: 2px solid var(--accent); }
.topic-name { font-weight: 700; }
.topic-group { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); margin-right: 0.5rem; }
.topic-group::after { content: " /"; }
.topic-summary, .prereq { display: block; font-size: 0.9rem; color: var(--muted); }
.prereq { font-family: var(--mono); font-size: 0.82rem; }
.level-block { border: 1px solid var(--ink); padding: 1rem 1.25rem; margin: 1rem 0; }
.level-block h4 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.level-tag { font-family: var(--mono); background: var(--ink); color: var(--paper); padding: 0.05rem 0.5rem; margin-right: 0.35rem; }
.chapters { list-style: none; padding: 0; columns: 2 14rem; }
.ch-num { font-family: var(--mono); color: var(--accent); font-size: 0.85rem; margin-right: 0.35rem; }
.price { font-family: var(--mono); font-size: 1.25rem; font-weight: 700; }

/* Blog */
.post-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.post-item { border-top: 1px solid var(--rule); padding: 1rem 0; }
.post-item time, .post-meta { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.post-item h3 { margin: 0.25rem 0 0.5rem; }
.post { padding: 2.5rem 0 3.5rem; }
.post h1 { font-size: clamp(1.75rem, 6.5vw, 2.6rem); }
.post h2 { font-size: 1.4rem; margin-top: 2.5rem; }
.post blockquote { margin: 1.5rem 0; padding: 0.75rem 1rem; border-left: 4px solid var(--accent); background: var(--tint); }
.post blockquote p:last-child { margin-bottom: 0; }
figure.code { margin: 1.25rem 0; }
figure.code .code-sample { margin: 0; }
.code-label { font-family: var(--mono); font-size: 0.8rem; font-weight: 700; margin: 0 0 0.25rem; color: var(--muted); }
.code-sample.is-output { background: var(--tint); color: var(--ink); border-left-color: var(--muted); }
.code-sample.is-wrong { border-left-color: var(--muted); }

/* Footer */

@media (max-width: 30rem) {
  body { font-size: 1rem; }
  section { padding: 2.5rem 0; }
  .hero { padding: 3rem 0 2.5rem; }
  .btn { width: 100%; text-align: center; }
  .site-nav ul { gap: 0.25rem 0.8rem; font-size: 0.9rem; }
  /* calendar tables: one card per row instead of 5 squeezed columns */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { border: 1px solid var(--rule); margin: 0 0 0.75rem; padding: 0.5rem 0.75rem; }
  .table-stack td { border: 0; padding: 0.15rem 0; }
  .table-stack td::before { content: attr(data-label) "："; font-weight: 700; }
  .table-stack td:empty { display: none; } /* keep all 7 nav items on one line at 390px */
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media print { .site-header nav, .skip, .actions { display: none; } a { text-decoration: none; } }

/* footer */
.site-footer { background: #111111; color: #b8b8b8; padding: 3.5rem 0 1.5rem; font-size: 0.92rem; line-height: 1.7; margin-top: 0; }
.site-footer a { color: #e6e6e6; text-decoration: none; }
.site-footer a:hover, .site-footer a:focus-visible { color: #ffffff; text-decoration: underline; text-decoration-color: var(--accent-soft); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.footer-grid { display: grid; gap: 2.5rem 3rem; grid-template-columns: minmax(14rem, 2fr) repeat(3, minmax(8rem, 1fr)); }
.footer-mark { display: block; height: 28px; width: auto; }
.footer-home { display: inline-block; margin-bottom: 1rem; }
.footer-about p { margin: 0 0 0.75rem; color: #b8b8b8; }
.footer-contact { font-family: var(--mono); font-size: 0.85rem; }
.site-footer h2 { font-family: var(--mono); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; color: var(--accent-soft); margin: 0.35rem 0 0.9rem; }
.site-footer h2::before { content: "// "; color: #6a6a6a; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 0 0 0.45rem; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; border-top: 1px solid #2b2b2b; margin-top: 3rem; padding-top: 1.25rem; font-size: 0.82rem; color: #8a8a8a; }
.footer-bottom p { margin: 0; }
.footer-bottom ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.footer-bottom li { margin: 0; }
.footer-bottom a { color: #a8a8a8; }
@media (max-width: 760px) {
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem 1.5rem; }
  .footer-about { grid-column: 1 / -1; }
}
