:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --text: #1b1f2a;
  --muted: #5d6474;
  --line: #e6e2d9;
  --brand: #2b3a8f;
  --brand-ink: #ffffff;
  --accent: #f08a24;
  --accent-soft: #fff1e2;
  --link: #2b3a8f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 8px 24px rgba(20, 24, 40, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1218;
  --surface: #161a23;
  --surface-2: #1d2230;
  --text: #e8eaf0;
  --muted: #9aa2b4;
  --line: #2a3040;
  --brand: #8ea2ff;
  --brand-ink: #0f1218;
  --accent: #ffa552;
  --accent-soft: #2a2117;
  --link: #a9b8ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #161a23; --surface-2: #1d2230; --text: #e8eaf0; --muted: #9aa2b4;
    --line: #2a3040; --brand: #8ea2ff; --brand-ink: #0f1218; --accent: #ffa552; --accent-soft: #2a2117;
    --link: #a9b8ff; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.65 var(--font); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: var(--brand-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.wrap { width: min(1180px, 100% - 40px); margin-inline: auto; }
.wrap-narrow { width: min(760px, 100% - 40px); margin-inline: auto; }

/* header */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 24px; height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), #5468d4 60%, var(--accent)); color: #fff; font-weight: 800; font-size: 15px; letter-spacing: .5px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-size: 17px; letter-spacing: -.2px; }
.brand-text small { font-size: 11.5px; font-weight: 700; letter-spacing: 2.2px; color: var(--accent); }
.main-nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.main-nav a { color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 550; padding: 8px 12px; border-radius: 999px; white-space: nowrap; }
.main-nav a:hover, .main-nav a[aria-current] { color: var(--text); background: var(--surface-2); }
.header-actions { display: flex; gap: 6px; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; font-size: 15px; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 860px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 10px 0; gap: 10px; }
  .main-nav { order: 3; width: 100%; margin: 0 -6px; }
  .header-actions { margin-left: auto; }
}

/* hero */
.hero { padding: 56px 0 28px; background: radial-gradient(1000px 400px at 85% -10%, var(--accent-soft), transparent 60%), radial-gradient(800px 380px at -10% 10%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 60%); }
.hero-inner { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; }
.kicker { text-transform: uppercase; letter-spacing: 1.6px; font-size: 12.5px; font-weight: 750; color: var(--accent); margin: 0 0 10px; }
.hero h1 { font-family: var(--serif); font-size: clamp(36px, 5vw, 58px); line-height: 1.05; letter-spacing: -1px; margin: 0 0 16px; }
.lead { font-size: 19px; color: var(--muted); margin: 0 0 24px; max-width: 46ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; padding: 12px 20px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-weight: 650; text-decoration: none; border: 1px solid var(--brand); }
.btn:hover { color: var(--brand-ink); filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); filter: none; }
@media (max-width: 900px) { .hero-inner { grid-template-columns: 1fr; gap: 28px; } .hero { padding-top: 32px; } }

.topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 20px; margin-bottom: 8px; }
.topic { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 16px 18px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); text-decoration: none; color: var(--text); transition: transform .15s, border-color .15s; }
.topic span { color: var(--muted); font-size: 14px; }
.topic:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--text); }

.section-h { font-family: var(--serif); font-size: 28px; letter-spacing: -.3px; margin: 40px 0 18px; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s; }
.card:hover { transform: translateY(-3px); }
.card-img { display: block; aspect-ratio: 800 / 440; background: var(--surface-2); overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.card:hover .card-img img { transform: scale(1.03); }
.card-img-fallback { display: grid; place-items: center; padding: 24px; text-decoration: none; background: linear-gradient(135deg, var(--brand), #5468d4 55%, var(--accent)); }
.card-img-fallback span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: #fff; font-family: var(--serif); font-size: 22px; line-height: 1.2; text-align: center; }
.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { font-size: 19px; line-height: 1.3; margin: 0; letter-spacing: -.2px; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--brand); }
.card-big .card-title { font-size: 24px; font-family: var(--serif); }
.card-excerpt { margin: 0; color: var(--muted); font-size: 15.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 14px; margin-top: auto; }
.chip { display: inline-flex; align-items: center; font: inherit; font-size: 12.5px; font-weight: 650; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 75%, var(--text)); text-decoration: none; border: 0; cursor: pointer; }
.chip:hover { color: var(--accent); }
.chip-tag { background: var(--surface-2); color: var(--muted); }

/* listing heads */
.page-head { padding: 48px 0 28px; border-bottom: 1px solid var(--line); margin-bottom: 32px; background: linear-gradient(180deg, var(--surface-2), transparent); }
.page-head h1 { font-family: var(--serif); font-size: clamp(32px, 4.4vw, 48px); line-height: 1.1; letter-spacing: -.8px; margin: 0 0 8px; }
.page-head .lead { margin-bottom: 6px; }

.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 40px 0 8px; }
.pg { min-width: 42px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); text-align: center; text-decoration: none; color: var(--text); font-weight: 600; }
.pg.current { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* article */
.post-head { padding: 48px 0 20px; }
.post-head h1 { font-family: var(--serif); font-size: clamp(32px, 4.6vw, 50px); line-height: 1.1; letter-spacing: -.9px; margin: 12px 0 14px; }
.post-hero { margin: 8px 0 8px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.post-hero img { width: 100%; }
.post-layout { display: grid; grid-template-columns: 1fr minmax(0, 720px) 1fr; gap: 40px; margin-top: 24px; }
.post-aside { grid-column: 1; justify-self: end; width: 100%; max-width: 230px; }
.prose { grid-column: 2; min-width: 0; }
.toc { position: sticky; top: 92px; font-size: 14px; border-left: 2px solid var(--line); padding-left: 14px; }
.toc-h { font-weight: 750; text-transform: uppercase; letter-spacing: 1.2px; font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.toc ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover, .toc a.active { color: var(--brand); }
@media (max-width: 1100px) { .post-layout { grid-template-columns: minmax(0, 1fr); width: min(760px, 100% - 40px); } .post-aside { display: none; } .prose { grid-column: 1; } }

.prose { font-size: 18px; line-height: 1.75; }
.prose > * + * { margin-top: 1.1em; }
.prose p { margin: 0 0 1.1em; }
.prose h2 { font-family: var(--serif); font-size: 30px; line-height: 1.2; letter-spacing: -.4px; margin: 1.8em 0 .6em; }
.prose h3 { font-size: 22px; line-height: 1.3; margin: 1.6em 0 .5em; }
.prose h4 { font-size: 18px; margin: 1.4em 0 .4em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li { margin: .3em 0; }
.prose li > h3, .prose li > h2 { margin: .8em 0 .2em; }
.prose img { border-radius: 10px; margin: 1.4em auto; box-shadow: var(--shadow); background: var(--surface-2); }
.prose figure { margin: 1.6em 0; }
.prose figcaption { text-align: center; color: var(--muted); font-size: 14px; margin-top: -.6em; }
.prose blockquote { margin: 1.5em 0; padding: 4px 0 4px 20px; border-left: 4px solid var(--accent); color: var(--muted); font-style: italic; }
.prose strong, .prose b { font-weight: 700; }
.table-wrap { overflow-x: auto; margin: 1.6em 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.prose table { width: 100%; border-collapse: collapse; font-size: 15.5px; line-height: 1.45; }
.prose td, .prose th { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose tr:first-child td, .prose th { background: var(--surface-2); font-weight: 700; }
.prose tr:last-child td { border-bottom: 0; }
.notice { padding: 14px 18px; border-radius: 12px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-size: 15.5px; }
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2.2em; }
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 1.4em; padding-top: 1.4em; border-top: 1px solid var(--line); font-size: 15px; }
.related { margin-top: 32px; }

.archive-list { list-style: none; padding: 0; margin: 0 0 12px; }
.archive-list li { display: grid; grid-template-columns: 70px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.archive-list time { color: var(--muted); font-size: 14px; padding-top: 2px; }
.archive-list a { color: var(--text); text-decoration: none; font-weight: 600; }
.archive-list a:hover { color: var(--brand); }

/* footer */
.site-footer { margin-top: 80px; border-top: 1px solid var(--line); background: var(--surface); padding: 44px 0 24px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; }
.footer-grid p { max-width: 40ch; }
.footer-h { font-size: 13px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); margin: 6px 0 12px; }
.footer-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.footer-links a { color: var(--text); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }
.footer-bottom { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 14px; }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }

/* search */
dialog#search-dialog { width: min(640px, 100% - 24px); margin: 10vh auto auto; padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: 0 24px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 12, 20, .45); backdrop-filter: blur(3px); }
.search-box { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); color: var(--muted); }
.search-box input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 18px; padding: 6px 0; }
.search-results { list-style: none; margin: 0; padding: 8px; max-height: 60vh; overflow: auto; }
.search-results a { display: block; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--text); }
.search-results a:hover, .search-results a:focus { background: var(--surface-2); outline: none; }
.search-results small { display: block; color: var(--muted); font-size: 13.5px; }
.search-results .empty { padding: 14px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
