:root {
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --text: #1e293b;
  --text-muted: #64748b;
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --border: #e2e8f0;
  --code-bg: #0f172a;
  --radius: 10px;
  --content-width: 760px;
  --header-bg: rgba(255, 255, 255, 0.95);
  --hover: #f1f5f9;
  --strong: #0f172a;
  --inline-code-bg: #eef2ff;
  --inline-code-fg: #4338ca;
  --inline-code-border: #e0e7ff;
  --row-alt: #fcfdff;
  --quote-color: #475569;
}

:root[data-theme="dark"] {
  --accent: #818cf8;
  --accent-dark: #a5b4fc;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --bg: #0f172a;
  --bg-subtle: #161f33;
  --border: #2c3a52;
  --code-bg: #0b1120;
  --header-bg: rgba(15, 23, 42, 0.92);
  --hover: rgba(148, 163, 184, 0.13);
  --strong: #f8fafc;
  --inline-code-bg: #1e293b;
  --inline-code-fg: #a5b4fc;
  --inline-code-border: #334155;
  --row-alt: #141d30;
  --quote-color: #94a3b8;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #818cf8;
    --accent-dark: #a5b4fc;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --bg: #0f172a;
    --bg-subtle: #161f33;
    --border: #2c3a52;
    --code-bg: #0b1120;
    --header-bg: rgba(15, 23, 42, 0.92);
    --hover: rgba(148, 163, 184, 0.13);
    --strong: #f8fafc;
    --inline-code-bg: #1e293b;
    --inline-code-fg: #a5b4fc;
    --inline-code-border: #334155;
    --row-alt: #141d30;
    --quote-color: #94a3b8;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(10px) saturate(1.4);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.05);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .inner,
.site-footer .inner,
.page {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 20px;
}

.site-header .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: 64px;
}

.site-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.site-title:hover { text-decoration: none; color: var(--accent); }

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #22d3ee);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  flex: none;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.site-nav {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  color: var(--text-muted);
  font-size: 14.5px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.site-nav a:hover {
  color: var(--text);
  background: var(--hover);
  text-decoration: none;
}
.site-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--inline-code-bg);
  font-weight: 600;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { display: block; }
.theme-toggle .icon-sun { display: none; }

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

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
}

.page { padding-top: 36px; padding-bottom: 60px; }

/* ---------- Hero (home page) ---------- */
.hero {
  margin: 2px 0 26px;
  padding: 36px 34px;
  background:
    radial-gradient(900px 320px at 8% -50%, rgba(79, 70, 229, 0.16), transparent 60%),
    radial-gradient(700px 300px at 92% -60%, rgba(14, 165, 233, 0.13), transparent 60%),
    var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 18px;
}
.hero h1 {
  margin: 0 0 10px;
  font-size: 37px;
  line-height: 1.15;
  letter-spacing: -0.025em;
}
.hero p {
  margin: 0;
  color: var(--text-muted);
  font-size: 17.5px;
  max-width: 620px;
}

/* ---------- Home list ---------- */
.post-list { list-style: none; margin: 0; padding: 0; }

.post-card {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}
.post-card:last-child { border-bottom: none; }

.post-card .card-body { flex: 1; min-width: 0; }

.post-card .thumb { flex: 0 0 205px; }
.post-card .thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
.post-card .thumb:hover img { border-color: var(--accent); }

.post-card.featured { padding-top: 4px; }
.post-card.featured .thumb { flex-basis: 330px; }
.post-card.featured h2 { font-size: 27px; }

.badge-latest {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 11px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.post-card h2 {
  margin: 0 0 7px;
  font-size: 21px;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.post-card h2 a { color: var(--text); }
.post-card h2 a:hover { color: var(--accent); text-decoration: none; }

.post-card .excerpt {
  margin: 0 0 11px;
  color: var(--text-muted);
  font-size: 15.5px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.meta .dot::before { content: "·"; margin-right: 10px; }

.label-chip {
  display: inline-block;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  margin-right: 6px;
}
a.label-chip:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 15px;
}
.pagination a {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 16px;
  font-weight: 600;
}
.pagination a:hover { border-color: var(--accent); text-decoration: none; }
.pagination .disabled { color: var(--border); border-color: var(--border); pointer-events: none; }

/* ---------- Article ---------- */
.article-header h1 {
  font-size: 34px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}

.article-header { margin-bottom: 28px; }
.article-header .labels { margin-top: 12px; }

article img,
.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

figure { margin: 28px 0; }
figcaption, .imageCaption {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  font-style: italic;
}

h2, h3, h4 {
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 40px 0 14px;
  scroll-margin-top: 76px;
}
h2 { font-size: 26px; }
h3 { font-size: 21px; }

p { margin: 0 0 20px; }

ul, ol { margin: 0 0 20px; padding-left: 26px; }
li { margin-bottom: 8px; }

blockquote {
  margin: 24px 0;
  padding: 14px 20px;
  border-left: 4px solid var(--accent);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--quote-color);
}
blockquote p:last-child { margin-bottom: 0; }

hr { border: none; border-top: 1px solid var(--border); margin: 36px 0; }

strong { color: var(--strong); }

/* ---------- Code ---------- */
code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}

code.inline-code {
  background: var(--inline-code-bg);
  color: var(--inline-code-fg);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--inline-code-border);
}

pre, .graf--pre {
  background: var(--code-bg);
  color: #e2e8f0;
  padding: 18px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 14.5px;
  line-height: 1.6;
  margin: 24px 0;
  position: relative;
}

pre code, .graf--pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: none;
  font-size: inherit;
}

.code-block { white-space: pre; }

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  font-size: 12px;
  padding: 3px 9px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255, 255, 255, 0.2); }

/* hljs tokens (legacy Medium-imported posts) */
.hljs-comment, .hljs-quote { color: #64748b; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal { color: #c084fc; }
.hljs-string, .hljs-attr { color: #86efac; }
.hljs-number, .hljs-symbol { color: #fbbf24; }
.hljs-title, .hljs-name, .hljs-function .hljs-title { color: #7dd3fc; }
.hljs-property, .hljs-attribute { color: #93c5fd; }
.hljs-built_in, .hljs-type { color: #67e8f9; }
.hljs-meta { color: #94a3b8; }

/* ---------- Tables ---------- */
.table { overflow-x: auto; margin: 24px 0; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
}
th, td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}
th { background: var(--bg-subtle); font-weight: 700; }
tr:nth-child(even) td { background: var(--row-alt); }

/* ---------- Post footer nav ---------- */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.post-nav a {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
}
.post-nav a:hover { border-color: var(--accent); text-decoration: none; }
.post-nav a span {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 3px;
}
.post-nav .next { text-align: right; }

.related { margin-top: 36px; }
.related h2 { font-size: 20px; margin-bottom: 14px; }
.related ul { list-style: none; padding: 0; margin: 0; }
.related li { margin-bottom: 10px; }

/* ---------- Section headers (archive/label/search) ---------- */
.list-header { margin-bottom: 10px; }
.list-header h1 { font-size: 30px; letter-spacing: -0.02em; margin: 0 0 6px; }
.list-header p { color: var(--text-muted); }

.archive-group { margin-bottom: 30px; }
.archive-group h2 { font-size: 19px; margin: 0 0 10px; color: var(--text-muted); }
.archive-group ul { list-style: none; padding: 0; margin: 0; }
.archive-group li { margin-bottom: 7px; }

/* ---------- Search ---------- */
.search-box { margin: 20px 0 30px; }
.search-box input {
  width: 100%;
  padding: 13px 16px;
  font-size: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
.search-box input:focus { border-color: var(--accent); }

/* ---------- CTA / promo blocks inside posts ---------- */
.post-body h2:first-child { margin-top: 0; }

/* ---------- Static pages ---------- */
.static-page h1 { font-size: 32px; letter-spacing: -0.02em; margin-top: 0; }

/* ---------- Reading progress bar (posts) ---------- */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #22d3ee);
  z-index: 60;
  pointer-events: none;
}

/* ---------- Breadcrumb (posts) ---------- */
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  min-width: 0;
}
.crumbs a { color: var(--text-muted); white-space: nowrap; }
.crumbs a:hover { color: var(--accent); text-decoration: none; }
.crumbs .sep { color: var(--border); flex: none; }
.crumbs > span:last-child {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ---------- Table of contents (posts) ---------- */
.toc {
  margin: 0 0 28px;
  padding: 13px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  font-size: 15px;
}
.toc summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  user-select: none;
}
.toc summary:hover { color: var(--accent); }
.toc nav {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 42vh;
  overflow-y: auto;
}
.toc a {
  color: var(--text-muted);
  padding: 4px 8px;
  border-left: 2px solid transparent;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toc a:hover { color: var(--accent); text-decoration: none; }
.toc a.h3 { padding-left: 22px; font-size: 14px; }
.toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

@media (min-width: 1280px) {
  .toc {
    position: fixed;
    top: 84px;
    left: calc(50% - 640px);
    width: 215px;
    margin: 0;
    padding: 12px 14px;
    max-height: calc(100vh - 120px);
    z-index: 40;
  }
  .toc nav { max-height: calc(100vh - 180px); }
}

/* ---------- Share buttons ---------- */
.share {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.share-label {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 4px;
}
.share-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 15px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
  line-height: 1.5;
}
.share-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(6px);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s, color 0.15s, border-color 0.15s;
  z-index: 55;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: none; }
.back-to-top:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Image lightbox ---------- */
.post-body img { cursor: zoom-in; }
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: zoom-out;
  padding: 20px;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  cursor: zoom-out;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 14.5px;
  color: var(--text-muted);
}
.site-footer .inner {
  padding-top: 26px;
  padding-bottom: 26px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 80px 0; }
.notfound h1 { font-size: 64px; margin: 0 0 8px; color: var(--accent); }
.notfound p { color: var(--text-muted); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero { padding: 26px 22px; }
  .hero h1 { font-size: 29px; }
  .post-card { flex-direction: column; gap: 14px; }
  .post-card .thumb, .post-card.featured .thumb { flex-basis: auto; width: 100%; }
  .post-card h2, .post-card.featured h2 { font-size: 20px; }
  .article-header h1 { font-size: 27px; }
  h2 { font-size: 22px; }
  .site-header .inner { height: auto; padding-top: 12px; padding-bottom: 10px; flex-direction: column; align-items: stretch; gap: 8px; }
  .header-right { width: 100%; justify-content: space-between; gap: 8px; }
  .site-nav a { padding: 6px 10px; font-size: 14px; }
  .logo-mark { width: 28px; height: 28px; font-size: 12px; border-radius: 8px; }
  .share-label { width: 100%; }
  .back-to-top { right: 14px; bottom: 14px; }
  .post-nav { flex-direction: column; }
}
