/* Notion-style page.
   White page, near-black warm text, hairline borders, an emoji page icon, a property table,
   toggle headings, callouts, colored tags and inline mentions. No cards or shadows.
   Motion is limited to toggles, hover states and the drifting source chips;
   everything is off under prefers-reduced-motion. */

:root {
  --bg: #ffffff;
  --fg: #37352f;
  --muted: #787774;                       /* 4.6:1 on white */
  --border: rgba(55, 53, 47, .09);
  --hover: rgba(55, 53, 47, .08);
  --callout: #f7f6f3;
  --link: rgba(55, 53, 47, .32);
  --accent: #2383e2;

  --gray-bg: #e3e2e0;   --gray-fg: #32302c;
  --blue-bg: #d3e5ef;   --blue-fg: #183347;
  --green-bg: #dbeddb;  --green-fg: #1c3829;
  --orange-bg: #fadec9; --orange-fg: #49290e;
  --purple-bg: #e8deee; --purple-fg: #412454;
  --pink-bg: #f5e0e9;   --pink-fg: #4c2337;
  --yellow-bg: #fdecc8; --yellow-fg: #402c1b;

  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC",
          "Microsoft JhengHei", Helvetica, "Apple Color Emoji", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
/* dark tokens: used for the system setting unless the visitor chose light, and for an explicit dark choice */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191919;
    --fg: #d4d4d4;
    --muted: #9b9b9b;
    --border: rgba(255, 255, 255, .094);
    --hover: rgba(255, 255, 255, .08);
    --callout: #252525;
    --link: rgba(255, 255, 255, .3);
    --accent: #529cca;
    --gray-bg: #454b4e;   --gray-fg: #e6e6e6;
    --blue-bg: #1f3a4d;   --blue-fg: #a9d4f2;
    --green-bg: #1e3a2a;  --green-fg: #a8d8b9;
    --orange-bg: #4a3220; --orange-fg: #f0c9a6;
    --purple-bg: #3a2a4a; --purple-fg: #d5bfe8;
    --pink-bg: #4a2638;   --pink-fg: #eec0d6;
    --yellow-bg: #4a3d1e; --yellow-fg: #ecd48f;
  }
}
:root[data-theme="dark"] {
  --bg: #191919;
  --fg: #d4d4d4;
  --muted: #9b9b9b;
  --border: rgba(255, 255, 255, .094);
  --hover: rgba(255, 255, 255, .08);
  --callout: #252525;
  --link: rgba(255, 255, 255, .3);
  --accent: #529cca;
  --gray-bg: #454b4e;   --gray-fg: #e6e6e6;
  --blue-bg: #1f3a4d;   --blue-fg: #a9d4f2;
  --green-bg: #1e3a2a;  --green-fg: #a8d8b9;
  --orange-bg: #4a3220; --orange-fg: #f0c9a6;
  --purple-bg: #3a2a4a; --purple-fg: #d5bfe8;
  --pink-bg: #4a2638;   --pink-fg: #eec0d6;
  --yellow-bg: #4a3d1e; --yellow-fg: #ecd48f;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.7 var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
  text-autospace: normal;            /* spacing between CJK and Latin text */
  text-spacing-trim: space-first;    /* squeeze adjacent CJK punctuation */
}
h1, h2 { text-wrap: balance; }
p, li { text-wrap: pretty; }
a { color: inherit; }
a:focus-visible, summary:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
::selection { background: rgba(45, 170, 219, .3); }

/* top bar: breadcrumb + theme toggle */
.topbar {
  position: sticky; top: 0; z-index: 5; height: 45px; padding: 0 12px;
  display: flex; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: 14px;
}
.crumbs { display: flex; align-items: center; min-width: 0; }
.crumb { display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px; border-radius: 4px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.crumb:hover { background: var(--hover); }
.crumb-sep { margin: 0 4px; color: var(--muted); opacity: .6; }
.crumb-desc { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-toggle {
  display: grid; place-items: center; width: 30px; height: 30px; padding: 0; flex: none;
  border: 0; border-radius: 4px; cursor: pointer; background: transparent; color: var(--muted);
  transition: background-color .12s, color .12s;
}
.theme-toggle:hover { background: var(--hover); color: var(--fg); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .sun { display: block; }
  :root:not([data-theme]) .theme-toggle .moon { display: none; }
}

/* page */
.page { max-width: 756px; margin: 0 auto; padding: 56px 24px 96px; }
.page-icon { font-size: 72px; line-height: 1; margin: 0 0 12px; }
.page-title { margin: 0; font-size: 40px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }
.page-title a { text-decoration: none; }
.page-desc { margin: 8px 0 20px; color: var(--muted); }

/* property table */
.props { padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.prop { display: grid; grid-template-columns: 160px minmax(0, 1fr); align-items: center; min-height: 34px; font-size: 14px; }
.prop-name { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.prop-name svg { width: 16px; height: 16px; flex: none; }
.prop-val { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.prop-val a { text-decoration-color: var(--link); text-underline-offset: 3px; }
.prop-val a:hover { background: var(--hover); }
.tag { display: inline-block; padding: 0 6px; border-radius: 3px; font-size: 14px; line-height: 20px; text-decoration: none !important; }
.tag:hover { filter: brightness(.96); background-blend-mode: multiply; }
.tag.gray { background: var(--gray-bg); color: var(--gray-fg); }
.tag.blue { background: var(--blue-bg); color: var(--blue-fg); }
.tag.green { background: var(--green-bg); color: var(--green-fg); }
.tag.orange { background: var(--orange-bg); color: var(--orange-fg); }
.tag.purple { background: var(--purple-bg); color: var(--purple-fg); }
.tag.pink { background: var(--pink-bg); color: var(--pink-fg); }
.tag.yellow { background: var(--yellow-bg); color: var(--yellow-fg); }

/* body blocks */
.callout {
  display: flex; gap: 8px; margin: 20px 0 8px; padding: 16px 16px 16px 12px;
  background: var(--callout); border-radius: 4px; font-size: 15px;
}
.callout-icon { flex: none; font-size: 20px; line-height: 1.5; }
.callout-body { min-width: 0; }
.callout-body p { margin: 0; }
.body p { margin: 4px 0; }
.body strong { font-weight: 600; }
.body a { text-decoration: underline; text-decoration-color: var(--link); text-underline-offset: 3px; }
.body a:hover { text-decoration-color: var(--fg); }
.body code { font: .85em var(--mono); background: var(--callout); color: #eb5757; padding: 1px 5px; border-radius: 3px; }
.body blockquote { margin: 8px 0; padding: 2px 0 2px 14px; border-left: 3px solid currentColor; }
.body hr, hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

/* toggle heading: arrow + h2 + count; click to fold */
.toggle { margin-top: 24px; }
.toggle summary {
  display: flex; align-items: center; gap: 2px; cursor: pointer; list-style: none; padding: 4px 0;
}
.toggle summary::-webkit-details-marker { display: none; }
.arrow { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 4px; color: var(--muted); }
.arrow::before {
  content: ""; border: solid transparent; border-width: 5px 0 5px 8px; border-left-color: currentColor;
  transition: rotate .15s ease;
}
.toggle[open] > summary .arrow::before { rotate: 90deg; }
.toggle summary:hover .arrow { background: var(--hover); }
.toggle h2 { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.3; }
.toggle .count { margin-left: 8px; color: var(--muted); font-size: 14px; }
.toggle-body { padding: 4px 0 0 26px; }
.toggle-body ul { margin: 0; padding-left: 1.3em; }
.toggle-body li { margin: 2px 0 10px; padding-left: 2px; }
.toggle-body li::marker { color: var(--muted); }

/* sources + archive sections */
.sources, .archive { margin-top: 48px; }
.sources h2, .archive h2 { margin: 0 0 12px; font-size: 24px; font-weight: 700; line-height: 1.3; }

/* database-style table */
.db { border-top: 1px solid var(--border); }
.db-row {
  display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px;
  padding: 6px 8px; margin: 0 -8px; border-bottom: 1px solid var(--border);
  font-size: 14px; color: inherit; text-decoration: none;
}
.db-head { color: var(--muted); }
a.db-row:hover { background: var(--hover); }
.db-row time { color: var(--muted); font-variant-numeric: tabular-nums; }

/* source mentions: favicon + name, like a Notion link mention */
.mention {
  display: inline-flex; align-items: center; gap: 4px; margin: 0 1px; padding: 0 4px; border-radius: 3px;
  font-size: .9em; line-height: 1.6; color: var(--fg); white-space: nowrap; vertical-align: baseline;
  text-decoration: underline; text-decoration-color: var(--link); text-underline-offset: 3px;
  transition: background-color .12s;
}
.mention img { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.body a.mention { text-decoration-line: underline; }
.mention:hover { background: var(--hover); }

/* floating source cloud: each chip drifts on its own slow loop; a physics loop makes them push apart */
.source-cloud {
  display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 40px;
  min-height: 14rem; padding: 40px 24px;
  border: 1px solid var(--border); border-radius: 4px;
  overflow-x: clip;          /* hidden tooltips must not make the page scroll sideways */
}
.mention.float {
  position: relative; top: var(--oy, 0); margin: 0; padding: 2px 9px 2px 7px;
  background: var(--callout); border: 1px solid var(--border); border-radius: 4px; text-decoration: none; font-size: 14px;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  animation: drift var(--dur, 7s) ease-in-out var(--delay, 0s) infinite alternate;
  transition: scale .18s ease, background-color .12s;
  will-change: transform;
}
/* hover, touch (press) and drag all enlarge the chip; `scale` is separate from position */
.mention.float:hover, .mention.float:active, .mention.float:focus-visible, .mention.float.dragging { scale: 1.18; }
.mention.float:hover, .mention.float:focus-visible { animation-play-state: paused; z-index: 2; background: var(--hover); }
.mention.float.dragging { cursor: grabbing; animation-play-state: paused; z-index: 3; background: var(--hover); box-shadow: 0 4px 14px rgba(0, 0, 0, .15); }
.mention.float::after {
  content: attr(data-title);
  position: absolute; left: 50%; bottom: calc(100% + 8px);
  width: max-content; max-width: min(18rem, 80vw); padding: 6px 10px;
  background: #252525; color: #fff; font-size: 12px; line-height: 1.5; white-space: normal; text-align: left;
  border-radius: 4px; transform: translateX(-50%);
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.mention.float.dragging::after { opacity: 0; }
.mention.float[data-tip="left"]::after { left: 0; transform: none; }
.mention.float[data-tip="right"]::after { left: auto; right: 0; transform: none; }
.mention.float:hover::after, .mention.float:focus-visible::after { opacity: 1; }
/* with JS: chips leave the flow and a small physics loop moves them (see build.py) */
.source-cloud.measuring .mention.float { animation: none; transform: none; }
.source-cloud.physics { display: block; position: relative; min-height: 0; }
.source-cloud.physics .mention.float {
  position: absolute; margin: 0; animation: none; transform: none;
  rotate: var(--rot, 0deg); will-change: translate;
}
@keyframes drift {
  from { transform: translate(0, 0) rotate(var(--rot, 0deg)); }
  to   { transform: translate(var(--dx, 8px), var(--dy, 8px)) rotate(calc(var(--rot, 0deg) * -1)); }
}

.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 14px; }
.pager a { text-decoration: none; padding: 2px 6px; margin: 0 -6px; border-radius: 4px; }
.pager a:hover { background: var(--hover); }
.pager .next { margin-left: auto; text-align: right; }
.empty { color: var(--muted); }

footer.site { max-width: 756px; margin: 0 auto; padding: 0 24px 56px; color: var(--muted); font-size: 12px; }

@media (max-width: 40rem) {
  .page { padding: 32px 16px 72px; }
  .page-icon { font-size: 56px; }
  .page-title { font-size: 30px; }
  .prop { grid-template-columns: 96px minmax(0, 1fr); }
  .toggle h2 { font-size: 21px; }
  .toggle-body { padding-left: 4px; }
  .db-row { grid-template-columns: 92px minmax(0, 1fr); }
  footer.site { padding: 0 16px 48px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
  .mention.float { animation: none; }
}
