/* ===== Tokens ===== */
:root {
  --paper: #F2F4F9;
  --surface: #FFFFFF;
  --ink: #0D1430;
  --soft: #4B5575;
  --faint: #5D6788;
  --line: #DDE2EE;
  --ring: #2F6BFF;
  --bar: #0A1028;
  --ui: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --read: "Source Serif 4", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --paper: #0A0F22;
  --surface: #131B38;
  --ink: #EEF1FB;
  --soft: #AEB6D2;
  --faint: #8790B0;
  --line: #232D52;
  --ring: #86AAFF;
  color-scheme: dark;
}

/* Each topic owns a colour: --c fills, --ct is the text-safe version */
.c0 { --c: #EE5A47; --ct: #C23A28; }
.c1 { --c: #EFA612; --ct: #9A5C00; }
.c2 { --c: #14B0A9; --ct: #0A7773; }
.c3 { --c: #3C74FF; --ct: #2250D8; }
.c4 { --c: #26AD62; --ct: #167A3C; }
.c5 { --c: #8461FA; --ct: #6243DE; }
[data-theme="dark"] .c0 { --ct: #FF8D7D; }
[data-theme="dark"] .c1 { --ct: #F6BB55; }
[data-theme="dark"] .c2 { --ct: #43D5CE; }
[data-theme="dark"] .c3 { --ct: #86AAFF; }
[data-theme="dark"] .c4 { --ct: #55D58F; }
[data-theme="dark"] .c5 { --ct: #AD9BFF; }

/* ===== Base ===== */
*, *::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: 400 16px/1.55 var(--ui); -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
::selection { background: color-mix(in srgb, var(--c, var(--ring)) 30%, transparent); }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; border-radius: 6px; }
.wrap { width: min(100% - 40px, 1240px); margin-inline: auto; }
.narrow { max-width: 780px; }
.section { padding-block: 56px; }
.center { text-align: center; margin-top: 40px; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 12px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--ink)); flex: none; }

/* ===== Ticker ===== */
.ticker { background: var(--bar); color: #E8ECF8; font-size: 13.5px; display: flex; align-items: stretch; overflow: hidden; }
.ticker-label { flex: none; padding: 9px 16px; font-weight: 700; background: #fff; color: #0A1028; }
.ticker-track { flex: 1; min-width: 0; overflow: hidden; display: flex; align-items: center;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent); }
.ticker-move { display: flex; flex: none; white-space: nowrap; animation: tick 80s linear infinite; }
.ticker-copy { display: flex; }
.ticker-move a { display: flex; align-items: center; gap: 10px; padding: 0 30px; }
.ticker-move a:hover { text-decoration: underline; text-underline-offset: 3px; }
.ticker:hover .ticker-move { animation-play-state: paused; }
@keyframes tick { to { transform: translateX(-50%); } }

/* ===== Header ===== */
.progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 70; pointer-events: none; }
.progress i { display: block; height: 100%; width: 0; background: var(--ink); }
.site-head { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--paper) 90%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4); border-bottom: 1px solid var(--line); }
.bar-in { display: flex; align-items: center; gap: 18px; padding-block: 16px 12px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font: 800 28px/1 var(--ui); letter-spacing: -.045em; }
.search { margin-left: auto; position: relative; flex: 0 1 360px; }
.search svg { position: absolute; left: 16px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input { width: 100%; padding: 11px 18px 11px 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 400 15px var(--ui); }
.search input::placeholder { color: var(--faint); }
.theme { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.rail-in { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 12px; }
.rail-in::-webkit-scrollbar { display: none; }
.rail a { flex: none; display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 15px; color: var(--soft); }
.rail a:hover { background: var(--surface); color: var(--ink); }
.rail a[aria-current] { background: var(--ink); color: var(--paper); }
.rail .grow { flex: 1; min-width: 12px; }

/* ===== Type + shared bits ===== */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.sec-title { font: 800 clamp(26px, 3vw, 36px)/1.05 var(--ui); letter-spacing: -.03em; }
.sec-head a { font-weight: 600; color: var(--soft); text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
.sec-head a:hover { color: var(--ink); }
.meta { display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: var(--faint); }
.meta .topic { font-weight: 700; color: var(--ct); display: inline-flex; align-items: center; gap: 8px; }
.meta .topic::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.meta .topic:hover { text-decoration: underline; text-underline-offset: 3px; }
.byline { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--faint); }
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 14px 26px; border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); font: 700 15px var(--ui); cursor: pointer; transition: transform .15s; }
.btn:hover { transform: translateY(-2px); }
.btn.ghost { background: transparent; color: var(--ink); }

/* Cover: the topic colour shows through if an image is missing */
.cover { display: block; aspect-ratio: 3 / 2; overflow: hidden; border-radius: 14px; background: color-mix(in srgb, var(--c, var(--ink)) 20%, var(--surface)); }
.cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
.cover:hover img { transform: scale(1.035); }

/* ===== Hero ===== */
.hero { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 56px; padding-block: 44px 24px; }
.hero-main .cover { aspect-ratio: 16 / 10; border-radius: 22px; margin-bottom: 22px; }
.hero-main h1 { font: 800 clamp(32px, 4.4vw, 56px)/1.04 var(--ui); letter-spacing: -.035em; margin: 12px 0 16px; text-wrap: balance; }
.hero-main h1 a:hover { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; text-decoration-color: var(--c); }
.hero-main p { font: 400 19px/1.65 var(--read); color: var(--soft); max-width: 62ch; margin-bottom: 18px; }
.hero-side { display: flex; flex-direction: column; justify-content: space-between; }
.mini { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 20px; align-items: start; padding-block: 24px; border-top: 1px solid var(--line); }
.mini:first-child { border-top: 0; padding-top: 0; }
.mini:last-child { padding-bottom: 0; }
.mini .cover { aspect-ratio: 4 / 3; border-radius: 12px; }
.mini h3 { font: 700 20px/1.25 var(--ui); letter-spacing: -.02em; margin-top: 8px; }
.mini h3 a:hover, .post h3 a:hover, .row-text h3 a:hover, .rank-title:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--c); }

/* ===== Topic tiles ===== */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.tile { min-height: 132px; padding: 20px 22px; border-radius: 18px; display: flex; flex-direction: column; justify-content: space-between; gap: 18px;
  background: color-mix(in srgb, var(--c) 15%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 32%, transparent); transition: box-shadow .2s; }
.tile b { font: 700 18px/1.2 var(--ui); letter-spacing: -.015em; }
.tile span { font-size: 14px; color: var(--soft); }
.tile:hover { box-shadow: inset 0 0 0 2px var(--c); }

/* ===== Lists & grids ===== */
.main-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 72px; align-items: start; }
.row-post { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 36px; align-items: center; padding-block: 30px; border-top: 1px solid var(--line); }
.row-post:first-of-type { border-top: 0; padding-top: 0; }
.row-post .cover { aspect-ratio: 4 / 3; }
.row-text h3 { font: 700 clamp(22px, 2.2vw, 28px)/1.18 var(--ui); letter-spacing: -.025em; margin: 10px 0 12px; }
.row-text p { font: 400 17px/1.65 var(--read); color: var(--soft); }
.side { position: sticky; top: 150px; }
.side .sec-title { margin-bottom: 8px; }
.rank { counter-reset: r; }
.rank li { counter-increment: r; display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 8px; padding-block: 20px; border-top: 1px solid var(--line); }
.rank li::before { content: counter(r); font: 800 36px/1 var(--ui); letter-spacing: -.05em; color: color-mix(in srgb, var(--ink) 24%, var(--paper)); }
.rank-title { font: 700 17px/1.3 var(--ui); letter-spacing: -.01em; display: block; margin-bottom: 6px; }
.notice { margin-top: 26px; padding: 18px 20px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font: 400 15px/1.6 var(--read); color: var(--soft); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 52px 32px; }
.post .meta { margin-top: 16px; }
.post h3 { font: 700 21px/1.25 var(--ui); letter-spacing: -.02em; margin-top: 8px; }
.post p { font: 400 16px/1.65 var(--read); color: var(--soft); margin-top: 10px; }

/* ===== Page head (topic, search, about...) ===== */
.page-head { padding-block: 56px 48px; background: color-mix(in srgb, var(--c, var(--ink)) 11%, var(--paper)); border-bottom: 1px solid var(--line); }
.page-head h1 { font: 800 clamp(38px, 6.4vw, 80px)/1 var(--ui); letter-spacing: -.045em; margin: 14px 0 12px; text-wrap: balance; }
.page-head p { font-size: 19px; color: var(--soft); }
.crumbs { display: flex; gap: 10px; font-size: 14px; color: var(--faint); }
.crumbs > * + *::before { content: "/"; margin-right: 10px; color: var(--line); }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }

/* ===== Article ===== */
.article-head { width: min(100% - 40px, 800px); margin: 56px auto 36px; }
.article-head h1 { font: 800 clamp(34px, 5.4vw, 60px)/1.04 var(--ui); letter-spacing: -.04em; margin: 20px 0 22px; text-wrap: balance; }
.byline .by-name { font-weight: 700; color: var(--ink); }
.article-cover { width: min(100% - 40px, 1160px); margin: 0 auto 56px; border-radius: 26px; overflow: hidden; background: color-mix(in srgb, var(--c) 20%, var(--surface)); aspect-ratio: 2 / 1; }
.article-cover img { width: 100%; height: 100%; object-fit: cover; }
.article-col { width: min(100% - 40px, 740px); margin: 0 auto; }
.share { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 40px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.share a, .share button { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--soft); font: 600 14px var(--ui); cursor: pointer; }
.share a:hover, .share button:hover { color: var(--ink); border-color: var(--ink); }
.prose { font: 400 20px/1.78 var(--read); color: var(--ink); overflow-wrap: break-word; }
.prose > * + * { margin-top: 1.3em; }
.prose h2 { font: 800 clamp(27px, 3.2vw, 34px)/1.15 var(--ui); letter-spacing: -.03em; margin-top: 2.1em; }
.prose h3 { font: 700 24px/1.25 var(--ui); letter-spacing: -.02em; margin-top: 1.8em; }
.prose h2 + *, .prose h3 + * { margin-top: .7em; }
.prose strong { font-weight: 600; }
.prose a { color: var(--ct, var(--ring)); text-decoration: underline; text-underline-offset: 4px; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li { padding-left: .3em; }
.prose li + li { margin-top: .5em; }
.prose li::marker { color: var(--c, var(--ink)); font-weight: 700; }
.prose blockquote { padding-left: 1.2em; border-left: 4px solid var(--c, var(--ink)); font-style: italic; color: var(--soft); }
.prose img { border-radius: 14px; height: auto; }
.prose table { width: 100%; border-collapse: collapse; font: 400 16px/1.5 var(--ui); display: block; overflow-x: auto; }
.prose th, .prose td { padding: 10px 14px; border: 1px solid var(--line); text-align: left; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); }
.tags a { padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; color: var(--soft); }
.tags a:hover { color: var(--ink); border-color: var(--ink); }
.related { margin-top: 40px; border-top: 1px solid var(--line); }

/* ===== Chips, empty states, forms ===== */
.empty { padding-block: 72px; max-width: 640px; }
.empty.big { padding-block: 120px; }
.empty h1, .empty h2 { font: 800 clamp(30px, 4.4vw, 52px)/1.05 var(--ui); letter-spacing: -.035em; margin-bottom: 14px; text-wrap: balance; }
.empty p { font: 400 19px/1.6 var(--read); color: var(--soft); }
.empty a:not(.btn):not(.chip) { text-decoration: underline; text-underline-offset: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.chip { display: inline-flex; align-items: center; gap: 9px; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 15px; }
.chip .dot { background: var(--c); }
.chip:hover { border-color: var(--c); }
.form { display: grid; gap: 22px; }
.field label { display: block; font-weight: 700; margin-bottom: 8px; }
.field input, .field textarea { width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 400 17px/1.5 var(--ui); }
.field textarea { resize: vertical; }
.form .btn { justify-self: start; }
.hp { position: absolute; left: -9999px; }
.note { padding: 16px 20px; border-radius: 14px; margin-bottom: 26px; font-weight: 600; }
.note.ok { background: color-mix(in srgb, #26AD62 16%, var(--surface)); border: 1px solid #26AD62; }
.note.err { background: color-mix(in srgb, #EE5A47 14%, var(--surface)); border: 1px solid #EE5A47; }

/* ===== Pager ===== */
.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 60px; }
.pager a, .pager span { min-width: 46px; height: 46px; padding-inline: 16px; display: grid; place-items: center; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; }
.pager a:hover { border-color: var(--ink); }
.pager [aria-current] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pager .gap { border: 0; background: none; padding: 0; min-width: 24px; }

/* ===== Footer ===== */
.site-foot { background: var(--bar); color: #AEB6D2; margin-top: 96px; padding-block: 72px 30px; }
.site-foot .logo { color: #fff; }
.foot-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 56px; }
.foot-about { margin-top: 20px; max-width: 38ch; font: 400 17px/1.65 var(--read); }
.site-foot h4 { color: #fff; font: 700 16px var(--ui); margin-bottom: 18px; }
.site-foot li + li { margin-top: 10px; }
.site-foot li a:hover { color: #fff; text-decoration: underline; text-underline-offset: 4px; }
.foot-note { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; margin-top: 56px; padding-top: 24px; border-top: 1px solid #1E2850; font-size: 14px; }

/* ===== Responsive ===== */
@media (max-width: 1020px) {
  .hero { grid-template-columns: 1fr; gap: 36px; }
  .hero-side { gap: 0; }
  .main-grid { grid-template-columns: 1fr; gap: 56px; }
  .side { position: static; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .section { padding-block: 40px; }
  .bar-in { flex-wrap: wrap; padding-block: 14px 10px; }
  .theme { margin-left: auto; }
  .search { order: 3; flex: 1 1 100%; margin-left: 0; }
  .grid { grid-template-columns: 1fr; gap: 40px; }
  .mini { grid-template-columns: 112px minmax(0, 1fr); gap: 14px; }
  .mini h3 { font-size: 17px; }
  .row-post { grid-template-columns: minmax(0, 1fr) 108px; gap: 16px; align-items: start; }
  .row-text p { display: none; }
  .row-text h3 { font-size: 19px; margin-block: 8px 0; }
  .article-cover { aspect-ratio: 16 / 10; border-radius: 18px; }
  .prose { font-size: 18.5px; }
  .foot-grid { grid-template-columns: 1fr; gap: 36px; }
  .hero-main p { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ticker-move { animation: none; }
  .ticker-track { overflow-x: auto; }
  .ticker-copy { display: none; }
  .cover img, .btn { transition: none; }
}
