/* blog.siao.ai — extends the siao.ai homepage's visual identity
 * (ClaudeDesign/BLOG.md), not the app family's. Same literal color
 * tokens as the homepage, same editorial detailing (hairlines,
 * letter-spaced labels, the ↗ hover affordance). One serif stack for
 * everything — no separate sans face for chrome.
 */

/* size-adjust exists because this site sets Latin and Traditional
 * Chinese in the same line constantly ("Markdown 渲染管線", "GFM 表格").
 *
 * Measured, not guessed: at the same font-size, EB Garamond's cap
 * height renders at 65.8px per 100px em while Noto Serif TC's glyph
 * height renders at 91.6px — the Latin is only 72% as tall, because
 * Garamonds are historically small-on-the-body faces and CJK glyphs
 * fill their em box. Unadjusted, every English word in a Chinese
 * sentence reads as a size too small.
 *
 * 108% brings the Latin cap to ~78% of the CJK glyph, which is the
 * comfortable ratio for a serif pairing. Applied to the @font-face
 * rather than to selectors, so it holds everywhere Latin appears
 * without anybody having to remember it.
 */
@font-face {
  font-family: "EB Garamond";
  src: url("/fonts/eb-garamond-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  size-adjust: 108%;
  font-display: block; /* a flash of the wrong serif reads worse than a moment of nothing */
}

@font-face {
  font-family: "EB Garamond";
  src: url("/fonts/eb-garamond-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  size-adjust: 108%;
  font-display: block;
}

@font-face {
  font-family: "EB Garamond";
  src: url("/fonts/eb-garamond-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  size-adjust: 108%;
  font-display: block;
}

@font-face {
  font-family: "Noto Serif TC";
  src: url("/fonts/noto-serif-tc-chinese-traditional-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: block;
}

@font-face {
  font-family: "Noto Serif TC";
  src: url("/fonts/noto-serif-tc-chinese-traditional-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: block;
}

:root {
  --paper: #faf9f6;
  --ink: #1a1a1a;
  --ink-dim: #6e6b65;
  --hairline: rgba(26, 26, 26, 0.14);

  /* Sage green, the siao.ai family's brand accent — the literal token
   * from ClaudeDesign/APP_FAMILY.md, not a re-derived approximation.
   * Already measured there: 4.52:1 as text on this paper, which is the
   * reason it is #587b60 and not the original #5f8567 (3.96:1).
   *
   * Used for interaction only — links, hover, focus, the reading
   * progress bar. Not for decoration, and never as the sole signal for
   * anything. */
  --accent: #587b60;
  --accent-wash: rgba(88, 123, 96, 0.09);
  --accent-hairline: rgba(88, 123, 96, 0.35);

  /* Code sits on a barely-tinted panel, not a slab (see the note on
   * `article pre`). Tokenised so dark mode can move it. */
  --code-panel: #f7f5f0;
  --code-inline: #f0eee8;




/* Two families, and the split is the point. Reading matter is set in
   * the serif; everything that is *interface* — nav, labels, byline,
   * sidebar, tag chips, table headers — is set in the system sans.
   *
   * Before this split every one of those was Garamond too, and a page
   * of nothing but serif at six different sizes is tiring to read: the
   * eye gets no signal about what is prose and what is furniture.
   * (The marketing homepage can be all-serif because it is one screen
   * with almost no chrome; this site is not that.)
   *
   * The sans is the platform's own — zero bytes downloaded, and it
   * reads as interface precisely because it is the interface face the
   * reader already knows. CJK order follows APP_FAMILY.md: TC before
   * SC, always, or shared codepoints render simplified. */
  --serif: "EB Garamond", "Noto Serif TC", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", "Noto Sans CJK TC", "Heiti TC", sans-serif;
}

/* Dark mode.
 *
 * ClaudeDesign/BLOG.md said "No dark mode, matching the homepage's
 * current decision" — overturned; the banner there records it.
 *
 * The palette is NOT new. These are the exact tokens siaohub already
 * ships (`siaohub/src/app/globals.css`), so a reader moving between
 * blog.siao.ai and git.siao.ai does not cross a seam. Re-deriving a
 * "close enough" dark grey is how a family stops looking like one.
 *
 * Measured against #17161a, not assumed:
 *   #e6e6e6 body text      14.43:1
 *   #9a9a9a muted           6.40:1
 *   #83b58c accent          7.68:1
 *   #e6e6e6 on the panel   13.12:1
 * and every dark-plus token against the #201f24 panel clears 4.5:1
 * (worst 4.91) — see the note in scripts/render-markdown.js.
 *
 * The light accent (#587b60) is 3.79:1 here — large-text only, not
 * enough for a link in running prose — which is why dark mode takes
 * the family's lighter #83b58c instead of reusing it. */
/* shiki bakes BOTH colours into every token as custom properties on the
 * span's own inline style; nothing sets `color`. This is what decides
 * which one is drawn, and without it a dual-theme block renders with no
 * syntax colour at all.
 *
 * The indirection has to happen here, on the span. An earlier version
 * declared `--shiki: var(--shiki-light)` on `:root` and used
 * `color: var(--shiki)` — but `--shiki-light` does not exist at the
 * root, so it was invalid at computed-value time and every token came
 * out black.
 *
 * Scoped to `pre`/`code` rather than a bare `[data-theme]`: the theme
 * toggle stamps `data-theme` on `<html>`, so the unscoped form matched
 * EVERY span on the page and set each one's colour from a variable that
 * does not exist there. */
pre[data-theme] span,
code[data-theme] span {
  color: var(--shiki-light);
}

/* Dark mode.
 *
 * ClaudeDesign/BLOG.md said "No dark mode, matching the homepage's
 * current decision" — overturned; the banner there records it.
 *
 * The palette is NOT new. These are the exact tokens siaohub already
 * ships (siaohub/src/app/globals.css), so a reader moving between
 * blog.siao.ai and git.siao.ai does not cross a seam. Re-deriving a
 * "close enough" dark grey is how a family stops looking like one.
 *
 * Measured against #17161a, not assumed:
 *   #e6e6e6 body text      14.43:1
 *   #9a9a9a muted           6.40:1
 *   #83b58c accent          7.68:1
 *   #e6e6e6 on the panel   13.12:1
 * and every dark-plus token against the #201f24 panel clears 4.5:1
 * (worst 4.91) — see the note in scripts/render-markdown.js.
 *
 * The light accent (#587b60) is 3.79:1 here — large text only, not
 * enough for a link in running prose — which is why dark mode takes
 * the family's lighter #83b58c rather than reusing it.
 *
 * This block must come AFTER the light `[data-theme] span` rule above:
 * same specificity, so source order decides, and a media query does not
 * change that. Written the other way round first, and the dark tokens
 * silently lost. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17161a;
    --ink: #e6e6e6;
    --ink-dim: #9a9a9a;
    --hairline: #2c2b30;
    --accent: #83b58c;
    --accent-wash: rgba(131, 181, 140, 0.12);
    --accent-hairline: rgba(131, 181, 140, 0.4);
    --code-panel: #201f24;
    --code-inline: #26252b;
  }

  pre[data-theme] span,
  code[data-theme] span {
    color: var(--shiki-dark);
  }
}

/* The manual override. `prefers-color-scheme` is the default; a reader
 * who has said otherwise gets what they said, on every page, before
 * paint (the init script in the head).
 *
 * Both directions are needed, not just the dark one: without the light
 * block, a reader on a dark system who chose light would still get the
 * media query. Same reason SiaoHub carries both. */
:root[data-theme="dark"] {
    --paper: #17161a;
    --ink: #e6e6e6;
    --ink-dim: #9a9a9a;
    --hairline: #2c2b30;
    --accent: #83b58c;
    --accent-wash: rgba(131, 181, 140, 0.12);
    --accent-hairline: rgba(131, 181, 140, 0.4);
    --code-panel: #201f24;
    --code-inline: #26252b;
}

:root[data-theme="dark"] pre[data-theme] span,
:root[data-theme="dark"] code[data-theme] span {
  color: var(--shiki-dark);
}

:root[data-theme="light"] {
  --paper: #faf9f6;
  --ink: #1a1a1a;
  --ink-dim: #6e6b65;
  --hairline: rgba(26, 26, 26, 0.14);
  --accent: #587b60;
  --accent-wash: rgba(88, 123, 96, 0.09);
  --accent-hairline: rgba(88, 123, 96, 0.35);
  --code-panel: #f7f5f0;
  --code-inline: #f0eee8;
}

:root[data-theme="light"] pre[data-theme] span,
:root[data-theme="light"] code[data-theme] span {
  color: var(--shiki-light);
}

/* The toggle, matched to AnswerHub's ghost button: 32px tall, fully
 * rounded, a muted wash on hover, a 14px icon in `currentColor`. Those
 * are the computed values of `<Button variant="ghost" size="sm">` over
 * there — copied as numbers because this site has no Tailwind to share
 * them with. */
.theme-toggle {
  appearance: none;
  background: none;
  border: none;
  padding: 0 0.6rem;
  margin: 0 0 0 0.35rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: var(--ink-dim);
  cursor: pointer;
  line-height: 1;
}

.theme-toggle svg {
  width: 0.875rem;
  height: 0.875rem;
  display: block;
}

.theme-toggle:hover {
  background: var(--accent-wash);
  color: var(--ink);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Which icon shows is decided here, not in script — see the note in
 * build.js. The moon offers dark; the sun offers a way back. */
.theme-toggle .icon-sun {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .theme-toggle .icon-moon {
    display: none;
  }
  .theme-toggle .icon-sun {
    display: block;
  }
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

:root[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

/* A label for anyone who cannot see the glyph. Not `display: none`,
 * which would take it out of the accessibility tree along with the
 * only thing that says what the button does. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  /* Sans is the default because most of what is on screen at any moment
   * is interface. Reading matter opts back into the serif below. */
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;

  /* 禁則處理: Chinese typesetting does not allow a line to *begin* with
   * closing punctuation (。、」）) or to *end* with opening punctuation.
   * Browsers default to `line-break: auto`, which is permissive and
   * regularly strands a 。 alone at the start of a line. This is the
   * single most visible difference between text that has been typeset
   * for Chinese and text that has merely been displayed in it. */
  line-break: strict;
  /* Don't break a Latin word mid-glyph when it sits inside Chinese
   * text; wrap it whole to the next line instead. */
  overflow-wrap: break-word;
}

a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--hairline);
}

a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* A visible focus ring in the brand colour. The default outline is the
 * browser's blue, which is the one colour on this page that belongs to
 * nobody — and removing it without a replacement is how keyboard
 * navigation gets quietly broken. */
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

/* Fills left-to-right as the reader scrolls through a post
 * (reading-progress.js). Zero width, invisible, and inert on any page
 * without an <article> — the script is a no-op there. */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 10;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* A post page is narrower, so the reading column ends up optically
 * centred in the viewport rather than sitting left of a sidebar that
 * isn't there. Measured against Medium's own article page, which
 * centres a 680px column with nothing beside it. */
.wrap-read {
  max-width: 712px; /* 680px column + the 1.5rem padding either side */
}

/* Two columns — reading column plus a persistent sidebar
 * (ClaudeDesign/BLOG.md: search, tags, recent posts always visible,
 * not one click away). Stacks to one column once there isn't room for
 * both without the sidebar crowding the reading measure. */
.layout {
  display: flex;
  gap: 3rem;
  align-items: flex-start;
}

.layout main {
  flex: 1;
  min-width: 0;
  max-width: 640px;
}

/* Reading shape: no sidebar, so main takes the full (already narrow)
 * wrap and the 680px measure comes from the wrap itself. */
.layout-read main {
  max-width: none;
}

@media (max-width: 720px) {
  .layout {
    flex-direction: column;
    /* `align-items: flex-start` above is what centres nothing and lets
     * the sidebar sit at the top of a row. In a COLUMN it means
     * something else entirely: the cross axis is now width, so each
     * child is sized to its max-content instead of the container.
     * For a page whose widest element is a code block or a wide table,
     * that is a hard overflow with no scrollbar on the element that
     * overflows — measured at 953px inside a 493px container. */
    align-items: stretch;
  }
  .layout main {
    max-width: none;
    min-width: 0;
  }
}

/* The site header: name + the tag/archive nav ClaudeDesign/BLOG.md's
 * "personal wiki" framing asks for, present on every page. */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.25rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--hairline);
}

/* The wordmark stays serif — it's the one piece of chrome that is
 * brand rather than interface. `.name` is an <h1> on the index and a
 * <span> elsewhere, so reset the h1 sizing it would otherwise inherit. */
.site-header .name {
  font-family: var(--serif);
  font-size: 1.4rem;
  line-height: 1.2;
  font-weight: 400;
  margin: 0;
}

.site-header .name a {
  border-bottom: none;
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
}

.site-nav a {
  border-bottom: none;
  color: var(--ink-dim);
}

.site-nav a:hover {
  color: var(--accent);
}

/* "You are here." The accent is doing real work — it is the only
 * persistent use of colour on a browse page, and it means exactly one
 * thing. Weight carries it too, so the state does not depend on colour
 * alone. */
.site-nav a[aria-current] {
  color: var(--accent);
  font-weight: 600;
}

/* Uppercase, letter-spaced section labels — same device the homepage
 * uses above its list groups (e.g. ELSEWHERE, CONTACT). */
.label {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 0.75rem;
}

/* Headings are reading matter, so they stay serif even on browse
 * pages where the surrounding chrome is sans. */
h1,
h2,
h3 {
  font-family: var(--serif);
}

h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.25;
  margin: 0 0 0.5rem;
}

/* A post's own headline — deliberately larger and more confident than
 * a section-index h1 (歸檔/標籤), the same "commit to the headline"
 * move Medium makes on an article page. */
.post-title {
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.15;
}

h2 {
  font-size: 1.3rem;
  margin: 2rem 0 0.75rem;
}

/* Sans, and small: this is metadata about the article, not part of it.
 * The family has to be stated, not inherited — the byline sits inside
 * <article>, which sets the serif for everything under it. */
.byline {
  font-family: var(--sans);
  color: var(--ink-dim);
  font-size: 0.85rem;
  margin: 0 0 1.75rem;
  letter-spacing: 0.01em;
}

/* Post/archive/tag listings share this shape: a hairline-divided list,
 * each item a title link plus a muted excerpt or meta line. */
/* No border-top: each item carries its own bottom rule, so the list
 * closes itself. It used to have one, which on the index stacked a
 * second hairline directly under the header's own bottom border —
 * two parallel lines with a gap and nothing between them. */
.post-list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
}

.post-list li {
  padding: 1.6rem 0;
  border-bottom: 1px solid var(--hairline);
}

/* The last one has no rule under it. The footer already draws a line,
 * and it is a different width — main's 624px against the wrap's 912px —
 * so the two read as one mistake rather than as two dividers.
 * `.widget-list` has had this rule from the start; this list did not. */
.post-list li:last-child {
  border-bottom: none;
}

/* The headline of a listing entry — upright and weighted, so it reads
 * as a title rather than as another line of the italic body voice the
 * excerpt below it uses. `font-style: normal` is load-bearing: the
 * rule below sets every `p` in a list item italic, and the title is a
 * `p` too. */
.post-list .title {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
}

.post-list .title a {
  border-bottom: none;
}

.post-list .title a:hover {
  color: var(--accent);
}

/* An excerpt is prose, so it stays serif; a meta line (post counts,
 * dates) is interface, so it doesn't. */
.post-list p {
  font-family: var(--serif);
  color: var(--ink-dim);
  font-style: italic;
  font-size: 1.05rem;
  margin: 0.4rem 0 0;
}

.post-list .meta {
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.85rem;
}

/* Tag chips — on a post page (linking to that tag's index) and on the
 * tag index itself (linking to each tag, with its post count).
 * Interface, so sans, and tinted with the brand wash on hover rather
 * than just darkening. */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1.75rem;
}

.tags a {
  font-family: var(--sans);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
  color: var(--ink-dim);
}

.tags a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-wash);
}

/* Archive: year headings, month sub-groups. */
.archive-year {
  font-size: 1.5rem;
  margin: 2.5rem 0 0.5rem;
}

.archive-year:first-of-type {
  margin-top: 0;
}

.archive-month {
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 1.25rem 0 0.5rem;
}

/* A post's own body content.
 *
 * Reading type is set HERE, not on `body` — the site chrome (nav,
 * sidebar, listings) stays at the smaller global size. Medium tunes
 * exactly this way: 20px/1.6 for article prose, smaller everywhere
 * else. Measured off their article page rather than guessed.
 */
article {
  margin-top: 0.5rem;
  font-family: var(--serif);
  font-size: 1.25rem; /* 20px */
  line-height: 1.6;
}

/* A link inside prose carries the accent from the start, not only on
 * hover — inside a paragraph there is no other cue that it is a link,
 * and hover is not a cue a touch reader ever receives. */
article a {
  color: var(--accent);
  border-bottom-color: var(--accent-hairline);
}

article a:hover {
  border-bottom-color: var(--accent);
  background: var(--accent-wash);
}

/* ~34px between paragraphs at this size, matching the measured
 * breathing room on Medium — noticeably more than the browser default,
 * and the single biggest thing that makes long prose feel readable
 * rather than dense. */
article p {
  margin: 0 0 1.7rem;
}

article h2 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 2.75rem 0 1rem;
}

article h3 {
  font-size: 1.25rem;
  margin: 2rem 0 0.75rem;
}

/* The headline block (title, byline, tags) sits closer together than
 * body prose, so it reads as one unit rather than three stacked
 * paragraphs. */
.post-title + .byline {
  margin-top: -0.25rem;
}

/* A markdown `---` becomes this — a centered "· · ·" scene break
 * instead of a plain rule, Medium's section-divider convention. The
 * author already writes `---` for this in GFM; nothing new to learn. */
article hr {
  border: none;
  height: auto;
  margin: 2.5rem 0;
  text-align: center;
}

article hr::after {
  content: "· · ·";
  /* The one ornamental mark on the page, so it wears the brand colour
   * rather than another grey. It carries no information, which is
   * exactly why colouring it costs nothing. */
  color: var(--accent);
  letter-spacing: 0.5em;
  font-size: 1.1rem;
}

/* Horizontal rules only — no vertical lines, no outer box. A full grid
 * on every cell reads as a spreadsheet; the same data with rules only
 * between rows reads as typeset. This is the same hairline the rest of
 * the site divides with, so a table sits in the page rather than on
 * top of it. */
article table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.95em;
}

article th,
article td {
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: 0.7rem 1rem 0.7rem 0;
  text-align: left;
  vertical-align: top;
}

article thead th {
  border-bottom-color: var(--ink);
  font-size: 0.8em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-dim);
  font-weight: 400;
  padding-bottom: 0.5rem;
}

article tbody tr:last-child td {
  border-bottom: none;
}

article figure {
  margin: 2rem 0;
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-radius: 3px;
}

/* A code block is a quotation of something else, not a hole punched in
 * the page. The dark shiki theme measured 13.93:1 against this paper —
 * a near-black slab that pulled the eye off the prose every time. A
 * light theme on a barely-tinted panel keeps the code legible as code
 * while leaving the page one continuous surface. */
article pre {
  overflow-x: auto;
  padding: 1.1rem 1.25rem;
  margin: 0;
  background: var(--code-panel) !important;
  border-radius: 3px;
  line-height: 1.55;
}

article code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
}

/* Inline code — distinguished by a tint, not a border, so it doesn't
 * fragment a sentence into boxes. */
article p > code,
article li > code {
  background: var(--code-inline);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* Language switcher, the same hairline/label device as everything
 * else — not a separate widget style. */
nav[aria-label="Languages"] {
  color: var(--ink-dim);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

nav[aria-label="Languages"] a,
nav[aria-label="Languages"] span {
  border-bottom: none;
}

/* "Referenced in" / embed-source notes render as quiet, italic asides
 * — the same register as the homepage's italic descriptions. */
p[role="note"] {
  color: var(--ink-dim);
  font-style: italic;
  font-size: 0.95rem;
}

/* Sidebar: search, tag cloud, recent posts, post count — all real
 * data, no placeholder categories (ClaudeDesign/BLOG.md). */
.sidebar {
  width: 240px;
  flex-shrink: 0;
}

@media (max-width: 720px) {
  .sidebar {
    width: 100%;
  }
}

.widget {
  margin-bottom: 2rem;
}

.widget .label {
  margin-bottom: 0.6rem;
}

.widget-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.widget-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 0.95rem;
}

.widget-list li:last-child {
  border-bottom: none;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-cloud a {
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
  color: var(--ink-dim);
}

.tag-cloud a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-wash);
}

.sidebar > .meta {
  color: var(--ink-dim);
  font-size: 0.85rem;
}

#search-input {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0.45rem 0.65rem;
}

#search-input:focus {
  border-color: var(--accent);
}

.search-results {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
}

.search-results li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
}

.search-results a {
  border-bottom: none;
}

.search-empty {
  color: var(--ink-dim);
  font-style: italic;
}

.site-footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hairline);
  color: var(--ink-dim);
  font-size: 0.9rem;
}

.site-footer a {
  border-bottom: none;
  color: var(--ink-dim);
}

.site-footer a:hover {
  color: var(--accent);
}


/* ── The journals beside an article ─────────────────────────────────
 *
 * The "read" shape deliberately has nothing alongside it: the reading
 * column is 680px inside a 712px wrap so it sits optically centred in
 * the viewport, measured against Medium's own article page.
 *
 * This panel is the one exception, and the distinction is what makes it
 * one. What a post page withholds is *site chrome* — search, tag cloud,
 * recent posts — navigation a reader mid-article is not using. These are
 * the primary sources for the argument they are reading right now, and
 * the point is to open one without losing your place.
 *
 * The trade is explicit: a post carrying journals is 1064px rather than
 * 712px, so its column is no longer centred in the viewport, it is
 * centred in a two-column page. Posts without journals are untouched.
 */

.wrap-read-docs {
  max-width: 1064px;
}

.wrap-read-docs .layout-read {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}

.wrap-read-docs .layout-read main {
  flex: 0 1 680px;
  min-width: 0;
}

.doc-panel {
  flex: 0 0 300px;
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  font-family: var(--sans);
  border-left: 1px solid var(--hairline);
  padding-left: 1.5rem;
}

.doc-panel h2 {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.doc-panel-note {
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0.5rem 0 1.1rem;
}

.doc-entry {
  border-top: 1px solid var(--hairline);
  padding: 0.7rem 0;
}

.doc-entry summary {
  cursor: pointer;
  list-style: none;
  display: block;
}

.doc-entry summary::-webkit-details-marker {
  display: none;
}

/* The affordance is a caret that turns, not a colour change — the
 * accent means "you are here" or "this is interactive", and every
 * entry being accent-coloured would say neither. */
.doc-entry summary::before {
  content: "▸";
  color: var(--muted);
  margin-right: 0.4rem;
  display: inline-block;
  transition: transform 0.12s ease;
}

.doc-entry[open] > summary::before {
  transform: rotate(90deg);
}

.doc-entry summary:hover .doc-title {
  color: var(--accent);
}

.doc-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
}

.doc-meta {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.15rem 0 0 1.1rem;
}

.doc-body {
  margin: 0.55rem 0 0.3rem 1.1rem;
  font-size: 0.82rem;
  line-height: 1.65;
}

.doc-summary {
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.doc-loading,
.doc-error {
  color: var(--muted);
  font-size: 0.8rem;
}

/* An injected journal is reference matter in a narrow column, so it is
 * set smaller than the article and left in the sans — it is being
 * consulted, not read at length. `整份打開` gives it the full measure. */
.doc-content {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--hairline);
  font-size: 0.78rem;
  line-height: 1.7;
}

.doc-content h1,
.doc-content h2,
.doc-content h3 {
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 600;
  margin: 1.4rem 0 0.4rem;
}

.doc-content h1 {
  margin-top: 0;
}

.doc-content pre {
  font-size: 0.72rem;
  padding: 0.7rem 0.8rem;
  overflow-x: auto;
}

.doc-content table {
  font-size: 0.72rem;
  display: block;
  overflow-x: auto;
}

.doc-content img {
  max-width: 100%;
}

@media (max-width: 1000px) {
  .wrap-read-docs {
    max-width: 712px;
  }
  .wrap-read-docs .layout-read {
    flex-direction: column;
    /* See the note on `.layout` above: in a column, `flex-start` sizes
     * children to max-content and the article overflows the viewport
     * with no scrollbar. */
    align-items: stretch;
  }
  .wrap-read-docs .layout-read main {
    flex: 1 1 auto;
    max-width: none;
  }
  .doc-panel {
    /* Stacked, it stays after the article — putting it first pushed the
     * headline 600px down the page, so the reader met a list of files
     * before they met the article.
     *
     * Reachability is the table of contents' job instead: its last entry
     * links straight here. Before that entry existed the panel sat at
     * y=23292px on a 39-minute article, which is a panel nobody can
     * reach. */
    position: static;
    max-height: none;
    overflow-y: visible;
    border-left: none;
    border-top: 1px solid var(--hairline);
    padding: 1.5rem 0 0;
    margin: 2.5rem 0 0;
    flex-basis: auto;
    width: 100%;
  }
}

/* ── Narrow viewports: what must scroll, and what must wrap ─────────
 *
 * Measured at 390px, where the page scrolled horizontally by 82px with
 * no scrollbar on anything that looked responsible.
 *
 * `pre` already had `overflow-x: auto`, which was not enough: shiki
 * renders `<pre><code>` and the `code` box takes the pre's content
 * width, so long lines spilled *out of* it rather than making it wide.
 * The pre therefore measured its content as ~348px and never scrolled,
 * while the lines themselves pushed the document out to 472px. Sizing
 * `code` to `max-content` is what gives the pre something real to
 * scroll; `min-width: 100%` keeps short blocks full-width so the
 * background does not shrink-wrap the text.
 */
article pre code,
.doc-content pre code {
  display: block;
  width: max-content;
  min-width: 100%;
}

/* An inline identifier can be longer than a phone is wide —
 * `game.qualiarts.hololive.dreams.com` is 34 characters with no space
 * in it. Prose wraps at spaces, so without this the paragraph is the
 * thing that overflows. */
article p > code,
article li > code,
article td > code,
.doc-content code {
  overflow-wrap: anywhere;
}

/* A wide table scrolls inside itself rather than widening the page. */
article table,
.doc-content table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
}

/* Long URLs in prose, same reason as inline code. */
article a {
  overflow-wrap: anywhere;
}

/* ── Table of contents ──────────────────────────────────────────────
 * A 39-minute article with no way to jump is a scroll bar and hope.
 * Set in the sans and unnumbered-looking, so it reads as apparatus
 * rather than as the article's first section.
 */
.toc {
  font-family: var(--sans);
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  padding: 1.1rem 0;
  margin: 2rem 0 2.5rem;
}

.toc h2 {
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.7rem;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 2rem;
}

.toc li {
  break-inside: avoid;
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  line-height: 1.45;
}

.toc a {
  border-bottom: none;
}

.toc a:hover {
  color: var(--accent);
}

@media (max-width: 560px) {
  .toc ol {
    columns: 1;
  }
}

/* The "本節來源" line closing each section. Set small and in the sans:
 * it is apparatus attached to the section, not a sentence of it. */
.doc-source-line,
article p:has(> a[href^="#doc-"]) {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
}

article p > a[href^="#doc-"] {
  border-bottom: none;
  color: var(--accent);
}

/* Arriving from a source link, the row it opens should be findable
 * without hunting: a brief tint says "this is the one". */
.doc-entry:target {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  border-radius: 3px;
}

/* ── Motion ─────────────────────────────────────────────────────────
 *
 * Every rule here sits inside `prefers-reduced-motion: no-preference`,
 * so the default for anyone who has asked for less motion is the
 * behaviour this site had before: instant jumps, instant disclosure.
 * The homepage makes the same promise and has a test for it.
 */

/* Landing flush against the top edge reads as "the page moved", not as
 * "you arrived somewhere". Applies with or without smooth scrolling —
 * it is spacing, not motion. */
article h2,
article h3,
.doc-entry,
#doc-panel {
  scroll-margin-top: 1.75rem;
}

@media (prefers-reduced-motion: no-preference) {
  /* Not `scroll-behavior: smooth`: its duration grows with distance,
   * and on this article that is 1.6 seconds. The animation lives in
   * reading-progress.js, which caps it. This stays `auto` so the two
   * do not fight over the same scroll. */

  /* A disclosure that snaps open moves everything below it with no
   * indication of where the new content came from. Animating the height
   * is what makes the panel read as one thing opening rather than as
   * the page reflowing.
   *
   * `interpolate-size: allow-keywords` is what allows the transition to
   * end at `auto`; without it the only animatable end state is a fixed
   * height, which cannot be right for content whose length is not known
   * until it is fetched. `content-visibility` needs `allow-discrete`
   * or the content vanishes at frame one on the way closed.
   *
   * Browsers without `::details-content` get today's behaviour: it
   * opens, immediately. */
  :root {
    interpolate-size: allow-keywords;
  }

  .doc-entry::details-content {
    block-size: 0;
    overflow: clip;
    transition:
      block-size 260ms cubic-bezier(0.32, 0.72, 0, 1),
      content-visibility 260ms allow-discrete;
  }

  .doc-entry[open]::details-content {
    block-size: auto;
  }

  /* The journal arrives after a fetch, which the height transition
   * above cannot cover: by the time the content lands, that transition
   * has already finished at the height of an empty box.
   *
   * Measured with the fragment delayed 900ms: the box eased open to
   * 205px, then jumped to 5294px in a single frame — five thousand
   * pixels, taking everything below it along.
   *
   * So the arriving content animates its OWN height. Injecting the
   * element is what starts it, which is the trigger a transition does
   * not have here. `block-size: 0 -> auto` is only interpolable because
   * of `interpolate-size` above; `overflow: clip` keeps the text from
   * spilling out of the box while it is shorter than its contents. */
  .doc-content {
    animation: doc-arrive 420ms cubic-bezier(0.4, 0, 0.2, 1) both;
    overflow: clip;
  }

  @keyframes doc-arrive {
    from {
      block-size: 0;
      opacity: 0;
    }
    40% {
      opacity: 0;
    }
  }
}
