/* Hosted changelog page (changelog.html). Layout: posts left, a sticky
   "On this page" list right; under 1100px the list moves into a sticky bar.
   The project's accent and theme come from changelog.js: it sets --accent and
   the readable variants (--ac-text-*, --ac-on-*, from widget/src/color.js) on
   <html>, and data-theme="dark" for a dark project or a dark system with Auto.
   changelog-theme.js sets the last seen theme and accent before the first paint. */

:root {
  --accent: #7c6fff;
  --on-accent: var(--ac-on-light, #fff);
  --bg: #fff;
  --text: #0b0f19;
  --text2: #3d4452;
  --muted: #6b7280;
  --border: #e8eaee;
  --line: #e2e5ea;
  --soft: #f4f5f7;
  --accent-text: var(--ac-text-light, color-mix(in srgb, var(--accent) 75%, #000));
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --scrim: rgba(11, 15, 25, .28);
  --shadow: 0 12px 32px rgba(11, 15, 25, .12), 0 2px 6px rgba(11, 15, 25, .06);
  --header-bg: rgba(255, 255, 255, .86);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', monospace;
  --header-h: 64px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d1017;
  --text: #eef2f7;
  --text2: #b4bfcc;
  --muted: #8a95a6;
  --border: #232a37;
  --line: #2a3343;
  --soft: #161b25;
  --accent-text: var(--ac-text-dark, color-mix(in srgb, var(--accent) 55%, #fff));
  --on-accent: var(--ac-on-dark, #fff);
  --accent-soft: color-mix(in srgb, var(--accent) 20%, transparent);
  --scrim: rgba(0, 0, 0, .5);
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --header-bg: rgba(13, 16, 23, .86);
  color-scheme: dark;
}

/* Until changelog-theme.js / changelog.js set data-theme: follow the system. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1017;
    --text: #eef2f7;
    --text2: #b4bfcc;
    --muted: #8a95a6;
    --border: #232a37;
    --line: #2a3343;
    --soft: #161b25;
    --accent-text: var(--ac-text-dark, color-mix(in srgb, var(--accent) 55%, #fff));
    --on-accent: var(--ac-on-dark, #fff);
    --accent-soft: color-mix(in srgb, var(--accent) 20%, transparent);
    --scrim: rgba(0, 0, 0, .5);
    --shadow: 0 12px 32px rgba(0, 0, 0, .45);
    --header-bg: rgba(13, 16, 23, .86);
    color-scheme: dark;
  }
}

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

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

.mono {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Header ─────────────────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
}
.top-in {
  max-width: 1200px; height: 100%; margin: 0 auto; padding: 0 40px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 32px; height: 32px; flex: none; border-radius: 9px; overflow: hidden;
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.logo.has-img { background: none; }
.logo img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; box-shadow: inset 0 0 0 .5px var(--border); }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-slash { color: var(--line); font-size: 18px; }
.brand-sub { color: var(--text2); font-size: 15px; white-space: nowrap; }
.updated { white-space: nowrap; }

/* ── Layout ─────────────────────────────────────────────────────────── */
.wrap {
  flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 40px;
  display: flex; gap: 88px; align-items: flex-start;
}
.main { flex: 1; min-width: 0; max-width: 780px; padding-bottom: 80px; }

/* ── Hero + toolbar ─────────────────────────────────────────────────── */
.hero { padding: 80px 0 40px; }
.eyebrow { letter-spacing: .14em; }
.hero h1 {
  margin-top: 16px;
  font-size: 52px; line-height: 1.05; font-weight: 600; letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}
.lede { margin-top: 18px; font-size: 20px; line-height: 1.5; color: var(--text2); }

.toolbar { margin-top: 36px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.search {
  position: relative; flex: 1 1 220px; max-width: 300px; height: 40px;
  display: flex; align-items: center;
  color: var(--muted);
}
.search svg { position: absolute; left: 14px; pointer-events: none; }
.search input {
  width: 100%; height: 100%; padding: 0 16px 0 38px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg);
  color: var(--text); font: inherit; font-size: 14px; outline: none;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input::-webkit-search-cancel-button { cursor: pointer; }

/* The chips wrap with the search field as one row of pills. */
.chips { display: contents; }
.chip {
  height: 40px; padding: 0 16px; border: 1px solid var(--border); border-radius: 999px;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 500; color: var(--text2); white-space: nowrap;
  transition: background-color 200ms var(--ease), border-color 200ms var(--ease), color 200ms var(--ease);
}
.chip:hover { border-color: var(--line); background: var(--soft); color: var(--text); }
.chip .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip[aria-pressed="true"] .count { color: color-mix(in srgb, var(--bg) 70%, transparent); }

/* Phone filter + search toggle (shown under 1100px) */
.filter, .search-toggle { display: none; }
.filter { position: relative; flex: 1; min-width: 0; }
.filter-btn {
  width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px;
  display: flex; align-items: center; gap: 10px; text-align: left;
  font-size: 15px; font-weight: 500;
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease);
}
.filter-btn:hover { background: var(--soft); }
.filter-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filter-btn .count, .menu .count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chev { flex: none; color: var(--muted); transition: transform 200ms var(--ease); }
[aria-expanded="true"] > .chev { transform: rotate(180deg); }

.search-toggle {
  width: 46px; height: 46px; flex: none; border: 1px solid var(--border); border-radius: 12px;
  align-items: center; justify-content: center; color: var(--text2);
  transition: background-color 200ms var(--ease), border-color 200ms var(--ease);
}
.search-toggle:hover, .search-toggle[aria-expanded="true"] { background: var(--soft); }

.menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 45;
  padding: 6px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--bg); box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(-6px) scale(.97); transform-origin: top center;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease), visibility 0s linear 200ms;
}
.menu.open {
  opacity: 1; visibility: visible; pointer-events: auto; transform: none;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease), visibility 0s;
}
.menu-item {
  width: 100%; height: 46px; padding: 0 12px; border-radius: 10px;
  display: flex; align-items: center; gap: 10px; text-align: left;
  font-size: 15px; color: var(--text2);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--soft); outline-offset: -2px; }
.menu-item[aria-checked="true"] { background: var(--soft); color: var(--text); font-weight: 600; }
.menu-item .filter-name { flex: 1; }
.menu-item .check { width: 16px; flex: none; color: var(--text); visibility: hidden; }
.menu-item[aria-checked="true"] .check { visibility: visible; }

/* ── Tags ───────────────────────────────────────────────────────────── */
/* Each tag class sets --tc (text + dot) and --tb (background). */
.t-all { --tc: var(--text); }
.t-new { --tc: var(--accent-text); --tb: var(--accent-soft); }
.t-improved { --tc: #0b6b5e; --tb: #e2f4f0; }
.t-performance { --tc: #075985; --tb: #e0f0fb; }
.t-security { --tc: #166534; --tb: #e6f4ea; }
.t-fixed { --tc: #9a3412; --tb: #fdeee4; }
.t-announcement { --tc: #6b21a8; --tb: #f3e8fc; }
.t-coming-soon { --tc: #854d0e; --tb: #fbf3db; }
.t-design { --tc: #9d174d; --tb: #fce7f1; }
.t-other { --tc: #4b5563; --tb: #eef0f3; }
[data-theme="dark"] .t-improved { --tc: #6fd9c5; }
[data-theme="dark"] .t-performance { --tc: #7cc4f0; }
[data-theme="dark"] .t-security { --tc: #86d99a; }
[data-theme="dark"] .t-fixed { --tc: #f5a77a; }
[data-theme="dark"] .t-announcement { --tc: #cfa8f5; }
[data-theme="dark"] .t-coming-soon { --tc: #e8c36a; }
[data-theme="dark"] .t-design { --tc: #f29bc4; }
[data-theme="dark"] .t-other { --tc: #aab4c3; }
[data-theme="dark"] .tag:not(.t-new) { --tb: color-mix(in srgb, var(--tc) 16%, transparent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .t-improved { --tc: #6fd9c5; }
  :root:not([data-theme="light"]) .t-performance { --tc: #7cc4f0; }
  :root:not([data-theme="light"]) .t-security { --tc: #86d99a; }
  :root:not([data-theme="light"]) .t-fixed { --tc: #f5a77a; }
  :root:not([data-theme="light"]) .t-announcement { --tc: #cfa8f5; }
  :root:not([data-theme="light"]) .t-coming-soon { --tc: #e8c36a; }
  :root:not([data-theme="light"]) .t-design { --tc: #f29bc4; }
  :root:not([data-theme="light"]) .t-other { --tc: #aab4c3; }
  :root:not([data-theme="light"]) .tag:not(.t-new) { --tb: color-mix(in srgb, var(--tc) 16%, transparent); }
}

.dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--tc, var(--muted)); }
.filter-btn .dot, .menu .dot { width: 8px; height: 8px; }

.tag {
  height: 24px; padding: 0 10px 0 9px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--tb); color: var(--tc);
  font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.tag::before { content: ''; width: 6px; height: 6px; flex: none; border-radius: 50%; background: currentColor; }

/* ── Posts ──────────────────────────────────────────────────────────── */
.post-card {
  border-top: 1px solid var(--border);
  padding: 56px 0 64px;
  scroll-margin-top: 88px;
}
.post-head { border-radius: 14px; margin: -12px; padding: 12px; }
.post-head.flash { animation: flash 1500ms var(--ease); }
@keyframes flash {
  0% { background-color: transparent; }
  20% { background-color: var(--accent-soft); }
  100% { background-color: transparent; }
}

.post-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
.post-title {
  margin-top: 18px;
  font-size: 36px; line-height: 1.12; font-weight: 600; letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}
.post-cover {
  display: block; width: 100%; height: auto; max-height: 440px; margin-top: 28px;
  border-radius: 18px; object-fit: cover; background: var(--soft);
}

/* Post body */
.prose { margin-top: 28px; font-size: 18px; line-height: 1.75; color: var(--text); overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 20px; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  margin: 36px 0 12px; font-size: 22px; line-height: 1.3; font-weight: 600; letter-spacing: -0.015em;
}
.prose h4, .prose .h4 { font-size: 18px; }
/* A post's own page lifts body headings one level (liftHeadings in worker/src/hosted.js). */
.prose .h3 { font-size: 22px; }
.prose ul, .prose ol { padding-left: 24px; margin: 0 0 20px; }
.prose li { margin-bottom: 6px; padding-left: 4px; }
.prose li::marker { color: var(--muted); }
.prose blockquote {
  margin: 0 0 20px; padding: 20px 24px; border-radius: 14px;
  background: var(--soft); color: var(--text2);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose img { max-width: 100%; height: auto; border-radius: 12px; display: block; margin: 24px 0; }
.prose a { color: var(--accent-text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.prose code {
  font-family: var(--mono); font-size: .85em;
  background: var(--soft); padding: 2px 6px; border-radius: 6px;
}
.prose pre {
  margin: 0 0 20px; padding: 16px 18px; border-radius: 12px;
  background: var(--soft); overflow-x: auto; line-height: 1.6;
}
.prose pre code { background: none; padding: 0; font-size: 14px; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-size: 16px; }
.prose th, .prose td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }

.lyt-video-embed { position: relative; width: 100%; aspect-ratio: 16/9; margin: 24px 0; border-radius: 12px; overflow: hidden; background: #000; }
.lyt-video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Reactions + copy link row */
.post-foot { margin-top: 40px; display: flex; align-items: flex-start; flex-wrap: wrap; gap: 12px 16px; }
.post-foot > .copy-link { margin-left: auto; }

.ghost {
  height: 44px; padding: 0 14px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 500; color: var(--text2); white-space: nowrap;
  transition: background-color 200ms var(--ease), color 200ms var(--ease);
}
.ghost:hover { background: var(--soft); color: var(--text); }
.copy-link svg { flex: none; }

/* Post reactions: same behaviour as the widget's post detail */
.lyt-rx {
  position: relative; flex: 1 1 auto; min-width: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px;
}
:where(.lyt-rx) :where(button, textarea) { font-family: inherit; color: inherit; }
.lyt-rx-q { min-height: 44px; display: flex; align-items: center; font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--text); }
.lyt-rx-r { display: flex; gap: 8px; }
.lyt-rx-b {
  position: relative; height: 44px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--text2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer;
  transition: transform 200ms var(--ease), background-color 200ms var(--ease), border-color 200ms var(--ease), color 200ms var(--ease);
}
.lyt-rx-b:hover { transform: translateY(-2px); border-color: var(--line); }
.lyt-rx-b:active { transform: scale(.96); }
.lyt-rx-b[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.lyt-rx-e {
  display: inline-block; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  font-size: 20px; font-weight: 400; line-height: 1;
  transition: transform 200ms var(--ease), filter 200ms var(--ease);
}
.lyt-rx-b[aria-pressed="true"] .lyt-rx-e { transform: scale(1.15); }
.lyt-rx.on .lyt-rx-b[aria-pressed="false"] .lyt-rx-e { filter: grayscale(1) opacity(.55); }
.lyt-rx-n { display: inline-block; font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.lyt-rx-b[aria-pressed="true"] .lyt-rx-n { color: var(--accent-text); }
.lyt-rx-pop { animation: lyt-rx-pop 520ms cubic-bezier(.34, 1.56, .64, 1); }
.lyt-rx-f { position: absolute; pointer-events: none; animation: lyt-rx-f 700ms var(--ease) forwards; }
.lyt-rx-g { position: absolute; inset: -1px; border: 2px solid var(--accent); border-radius: inherit; pointer-events: none; animation: lyt-rx-g 600ms var(--ease) forwards; }
.lyt-rx-u { animation: lyt-rx-u 360ms var(--ease); }
.lyt-rx-in { animation: lyt-rx-in 220ms var(--ease) both; }
@keyframes lyt-rx-pop { 0% { transform: scale(1); } 35% { transform: scale(1.45) rotate(-12deg); } 60% { transform: scale(.95) rotate(6deg); } 80% { transform: scale(1.2); } 100% { transform: scale(1.15); } }
@keyframes lyt-rx-f { 0% { opacity: 0; transform: scale(.6); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-46px) scale(1.25); } }
@keyframes lyt-rx-g { 0% { opacity: .55; transform: scale(.9); } 100% { opacity: 0; transform: scale(1.35); } }
@keyframes lyt-rx-u { 40% { transform: translateY(-4px); } }
@keyframes lyt-rx-in { 0% { opacity: 0; transform: translateY(-4px); } }
.lyt-rx-x { flex-basis: 100%; max-width: 520px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--soft); }
.lyt-rx-x:empty { display: none; }
.lyt-rx-o { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 14px; color: var(--muted); }
.lyt-rx-l { height: 32px; padding: 0 4px; color: var(--accent-text); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.lyt-rx-l:hover { text-decoration: underline; }
.lyt-rx-fm { display: flex; flex-direction: column; gap: 8px; }
.lyt-rx-fm label { font-size: 14px; font-weight: 600; color: var(--text); }
.lyt-rx-h { margin-top: -4px; font-size: 13px; color: var(--muted); }
.lyt-rx-ta {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
  font-size: 15px; line-height: 1.5; resize: none; outline: none;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.lyt-rx-ta:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lyt-rx-c { margin-top: -4px; font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.lyt-rx-a { display: flex; justify-content: flex-end; gap: 8px; }
.lyt-rx-k { height: 36px; padding: 0 14px; border-radius: 999px; color: var(--muted); font-size: 14px; font-weight: 500; }
.lyt-rx-k:hover { color: var(--text); }
.lyt-rx-send { height: 36px; padding: 0 16px; border-radius: 999px; background: var(--text); color: var(--bg) !important; font-size: 14px; font-weight: 600; }
.lyt-rx-send:disabled { opacity: .5; cursor: default; }
.lyt-rx-s { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text2); }
.lyt-rx-s svg { color: var(--accent-text); flex: none; }
.lyt-rx-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Empty / loading ────────────────────────────────────────────────── */
.loading, .empty-state { padding: 72px 0; color: var(--muted); font-size: 16px; border-top: 1px solid var(--border); }
.empty-state h2 { font-size: 22px; font-weight: 600; color: var(--text); letter-spacing: -0.015em; margin-bottom: 8px; }
.no-match { padding: 56px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.no-match p { font-size: 18px; font-weight: 600; }
.no-match .ghost { margin-left: -14px; color: var(--accent-text); }

/* Server-rendered extras (worker/src/hosted.js): the title links to the
   post's own page, "Older updates" pages, a single post's way back and neighbours. */
.post-title a { color: inherit; text-decoration: none; }
.post-title a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.pager { display: flex; justify-content: space-between; gap: 12px; padding: 32px 0 0; border-top: 1px solid var(--border); }
.pager .ghost { margin: 0 -14px; color: var(--accent-text); font-weight: 600; }
.pager-older { margin-left: auto !important; }
.pager .ghost[aria-busy] { opacity: .6; }
.hero-post { padding-bottom: 0; }
.back {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; margin-left: -6px; padding: 0 10px 0 6px;
  border-radius: 999px; color: var(--text2); font-size: 15px; font-weight: 500; text-decoration: none;
  transition: background-color 200ms var(--ease), color 200ms var(--ease);
}
.back:hover { background: var(--soft); color: var(--text); }
.post-single .post-card { border-top: 0; padding-top: 24px; }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-top: 32px; border-top: 1px solid var(--border); }
.pn {
  display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: 14px; color: var(--text); text-decoration: none;
  transition: background-color 200ms var(--ease), border-color 200ms var(--ease);
}
.pn:hover { background: var(--soft); }
.pn span { font-weight: 600; overflow-wrap: anywhere; }
.pn-older { grid-column: 2; text-align: right; }

/* ── On this page (desktop) ─────────────────────────────────────────── */
.toc {
  position: sticky; top: var(--header-h);
  width: 260px; flex: none;
  padding: 88px 0 32px;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding-right: 6px;
  /* The thumb shows only on hover, keyboard focus or while the list scrolls
     (.is-scrolling, changelog.js); at rest the edge fades say there is more. */
  --toc-thumb: color-mix(in srgb, var(--muted) 45%, transparent);
}
/* Firefox: the standard properties. Not in Chrome/Edge/Safari: there any
   scrollbar-width/-color switches to the native bar (with arrow buttons on
   Windows) and ignores the ::-webkit-scrollbar styles below. */
@supports not selector(::-webkit-scrollbar) {
  .toc { scrollbar-width: thin; scrollbar-color: transparent transparent; }
  .toc:hover, .toc:focus-within, .toc.is-scrolling { scrollbar-color: var(--toc-thumb) transparent; }
}
/* Chrome, Edge, Safari: a styled 6px bar, a thumb only, no arrow buttons.
   The thumb is the aside's currentColor: Chrome repaints the bar when the
   aside's own color changes, not on :hover/class rules for the pseudo-element.
   (Everything in the aside sets its own text color.) */
.toc::-webkit-scrollbar { width: 6px; }
.toc::-webkit-scrollbar-track { background: transparent; }
.toc::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
@supports selector(::-webkit-scrollbar) {
  .toc { color: transparent; }
  .toc:hover, .toc:focus-within, .toc.is-scrolling { color: var(--toc-thumb); }
  .toc::-webkit-scrollbar-thumb { background: currentColor; }
}
/* Edge fades only when the list overflows; which edges: changelog.js (paintTocFade). */
.toc.fade-bottom {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
}
.toc.fade-top {
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px);
  mask-image: linear-gradient(to bottom, transparent, #000 28px);
}
.toc.fade-both {
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}
.toc-h { letter-spacing: .14em; margin-bottom: 18px; }
.toc-list { position: relative; border-left: 1px solid var(--line); }
.toc-month { padding: 16px 0 4px 18px; font-size: 11px; letter-spacing: .12em; }
.toc-month:first-child { padding-top: 4px; }
.toc-item {
  display: block; padding: 9px 8px 9px 18px; text-decoration: none;
  color: var(--muted); border-radius: 0 8px 8px 0;
  transition: color 200ms var(--ease);
}
.toc-item:hover { color: var(--text2); }
.toc-item:focus-visible { outline-offset: -2px; }
.toc-t { display: block; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.toc-d { display: block; margin-top: 2px; font-size: 11px; }
.toc-item[aria-current="true"] { color: var(--text); }
.toc-item[aria-current="true"] .toc-t { font-weight: 500; }
.toc-ind {
  position: absolute; left: -1px; top: 0; width: 2px; height: 0;
  background: var(--text); border-radius: 2px;
  transition: transform 380ms cubic-bezier(.4, 0, .2, 1), height 380ms cubic-bezier(.4, 0, .2, 1);
}

/* ── On this page (phone bar) ───────────────────────────────────────── */
.toc-m { display: none; }
.scrim {
  position: fixed; inset: 0; z-index: 30; background: var(--scrim);
  animation: fade-in 200ms var(--ease);
}
@keyframes fade-in { from { opacity: 0; } }

/* ── Footer ─────────────────────────────────────────────────────────── */
.foot { border-top: 1px solid var(--border); }
.foot-in {
  max-width: 1200px; margin: 0 auto; padding: 32px 40px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 14px; color: var(--muted);
}
.badge {
  height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px;
  display: inline-flex; align-items: center;
  font-size: 13px; font-weight: 500; color: var(--text2); text-decoration: none;
  transition: background-color 200ms var(--ease), color 200ms var(--ease);
}
.badge:hover { background: var(--soft); color: var(--text); }

/* ── Under 1100px: no aside, phone toolbar, sticky "On this page" bar ── */
@media (max-width: 1100px) {
  .toc { display: none; }
  .wrap { display: block; }
  .main { max-width: 780px; margin: 0 auto; }

  .chips { display: none; }
  .filter { display: block; }
  .search-toggle { display: inline-flex; }
  .search { display: none; order: 3; flex-basis: 100%; max-width: none; height: 46px; }
  .toolbar.search-open .search { display: flex; }
  .search input { border-radius: 12px; font-size: 16px; }

  .toc-m {
    display: block; position: sticky; top: var(--header-h); z-index: 40;
    margin: 0 -40px;
  }
  .toc-m[hidden] { display: none; }
  .toc-m-btn {
    width: 100%; height: 52px; padding: 0 40px;
    display: flex; align-items: center; gap: 12px; text-align: left;
    background: var(--header-bg);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .toc-m-label { flex: none; font-size: 11px; letter-spacing: .12em; }
  .toc-m-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .toc-m-pos { flex: none; font-variant-numeric: tabular-nums; }
  .toc-m-btn:focus-visible { outline-offset: -2px; }

  .toc-m-panel {
    position: absolute; top: 100%; left: 0; right: 0;
    max-height: 60vh; overflow-y: auto; overscroll-behavior: contain;
    padding: 12px 40px 16px;
    background: var(--bg); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
    opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-6px);
    transition: opacity 200ms var(--ease), transform 200ms var(--ease), visibility 0s linear 200ms;
  }
  .toc-m.open .toc-m-panel {
    opacity: 1; visibility: visible; pointer-events: auto; transform: none;
    transition: opacity 200ms var(--ease), transform 200ms var(--ease), visibility 0s;
  }
  .toc-m .toc-item { min-height: 44px; position: relative; }
  .toc-m .toc-item[aria-current="true"]::before {
    content: ''; position: absolute; left: -1px; top: 0; bottom: 0; width: 2px; background: var(--text); border-radius: 2px;
  }

  .post-card { scroll-margin-top: 124px; }
}

@media (max-width: 640px) {
  .top-in { padding: 0 16px; }
  .brand-slash, .brand-sub { display: none; }
  .wrap { padding: 0 16px; }
  .foot-in { padding: 28px 16px; }
  .toc-m { margin: 0 -16px; }
  .toc-m-btn, .toc-m-panel { padding-left: 16px; padding-right: 16px; }
  .toc-m-btn { gap: 10px; }

  .hero { padding: 48px 0 28px; }
  .hero h1 { font-size: 38px; }
  .lede { font-size: 18px; }
  .toolbar { margin-top: 28px; }

  .post-card { padding: 40px 0 48px; }
  .post-title { font-size: 28px; }
  .post-cover { margin-top: 22px; border-radius: 14px; }
  .prose { font-size: 17px; }

  .lyt-rx-r { width: 100%; }
  .lyt-rx-b { flex: 1; min-width: 0; padding: 0 10px; }
  .post-foot > .copy-link { margin-left: -14px; }
  .post-nav { grid-template-columns: 1fr; }
  .pn-older { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .post-head.flash { animation: none; }
  .toc-ind, .menu, .menu.open, .toc-m-panel, .toc-m.open .toc-m-panel, .chev { transition: none !important; }
  .scrim { animation: none; }
  .lyt-rx-b, .lyt-rx-e { transition: none; }
  .lyt-rx-b:hover, .lyt-rx-b:active { transform: none; }
  .lyt-rx-pop, .lyt-rx-u, .lyt-rx-in { animation: none; }
  .lyt-rx-f, .lyt-rx-g { display: none; }
}
