/* ----------  Reset & base  ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
:root {
  --bg: #fbfaf7;
  --bg-elev: #ffffff;
  --bg-soft: #f3efe8;
  --ink: #232323;
  --ink-soft: #5a5a5a;
  --ink-mute: #8a8a8a;
  --line: #ece7df;
  --line-strong: #d9d2c4;
  --brand: #c2410c;          /* warm rust */
  --brand-soft: #fde4d3;
  --brand-ink: #7c2d12;
  --accent: #2563eb;
  --code-bg: #f6f1e8;
  --shadow-sm: 0 1px 2px rgba(40, 30, 20, 0.04);
  --shadow-md: 0 6px 18px rgba(40, 30, 20, 0.06), 0 1px 2px rgba(40, 30, 20, 0.04);
  --shadow-lg: 0 18px 40px rgba(40, 30, 20, 0.10), 0 2px 6px rgba(40, 30, 20, 0.05);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --maxw: 1180px;
  --font-sans: "Inter", "PingFang SC", "Microsoft Yahei", "Noto Sans SC",
               -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #14130f;
  --bg-elev: #1c1b17;
  --bg-soft: #23211c;
  --ink: #ece8e0;
  --ink-soft: #b9b3a7;
  --ink-mute: #837e72;
  --line: #2c2a25;
  --line-strong: #3a3731;
  --brand: #f59e0b;
  --brand-soft: #3a2615;
  --brand-ink: #fcd5a3;
  --accent: #93c5fd;
  --code-bg: #1f1d18;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.5);
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

img { max-width: 100%; }

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

/* ----------  Header  ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex;
  align-items: center;
  height: 64px;
  gap: 28px;
}
.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.2px;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #f59e0b);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.brand:hover { text-decoration: none; }
.nav-links { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.nav-links a {
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
}
.nav-links a:hover { color: var(--ink); background: var(--bg-soft); text-decoration: none; }
.nav-links a.active {
  color: var(--brand-ink);
  background: var(--brand-soft);
}
.theme-btn {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-soft);
  width: 36px; height: 36px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  margin-left: 6px;
}
.theme-btn:hover { color: var(--ink); border-color: var(--line-strong); }

/* ----------  Hero  ---------- */
.hero {
  padding: 88px 0 56px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -40% -10% auto -10%;
  height: 520px;
  background:
    radial-gradient(closest-side, rgba(245, 158, 11, 0.18), transparent 70%) 18% 30% / 55% 80% no-repeat,
    radial-gradient(closest-side, rgba(37, 99, 235, 0.14), transparent 70%) 82% 22% / 50% 70% no-repeat;
  filter: blur(2px);
  z-index: 0;
  pointer-events: none;
}
.hero-inner {
  position: relative;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 56px;
  align-items: center;
}
.hero h1 {
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
  color: var(--ink);
}
.hero h1 .accent {
  background: linear-gradient(120deg, var(--brand) 0%, #f59e0b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p.lead {
  font-size: 17px;
  color: var(--ink-soft);
  margin: 0 0 28px;
  max-width: 560px;
}
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: 0.2s;
}
.btn-primary {
  background: var(--ink);
  color: var(--bg);
}
.btn-primary:hover { background: var(--brand); color: white; text-decoration: none; }
.btn-ghost {
  background: var(--bg-elev);
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--line-strong); text-decoration: none; }

.hero-side {
  position: relative;
  display: flex;
  justify-content: center;
}
.avatar-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 360px;
  transform: rotate(0.4deg);
}
.avatar-card .row { display: flex; gap: 14px; align-items: center; }
.avatar-card img {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 2px var(--brand-soft);
}
.avatar-card .name { font-weight: 700; font-size: 18px; color: var(--ink); }
.avatar-card .login { font-size: 13px; color: var(--ink-mute); font-family: var(--font-mono); }
.avatar-card .stat-grid {
  margin-top: 18px;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.avatar-card .stat {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
}
.avatar-card .stat .num { font-size: 20px; font-weight: 700; color: var(--ink); }
.avatar-card .stat .lbl { font-size: 11px; color: var(--ink-mute); margin-top: 2px; }
.skill-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 18px;
}
.tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--bg-soft);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.tag.brand { color: var(--brand-ink); background: var(--brand-soft); border-color: transparent; }

/* ----------  Section  ---------- */
section.block { padding: 56px 0; }
.section-head {
  display: flex; align-items: end; justify-content: space-between;
  gap: 16px; margin-bottom: 28px;
  flex-wrap: wrap;
}
.section-head .title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--brand);
  font-weight: 700;
  margin-bottom: 6px;
}
.section-head h2 {
  font-size: 30px;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.section-head p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
}
.see-all {
  font-size: 14px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 999px;
}
.see-all:hover { color: var(--ink); text-decoration: none; border-color: var(--line-strong); }

/* ----------  Cards  ---------- */
.grid {
  display: grid;
  gap: 20px;
}
.grid.projects { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.notes    { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card {
  display: flex; flex-direction: column;
  gap: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  text-decoration: none;
  color: inherit;
  transition: 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--brand), #f59e0b);
  opacity: 0;
  transition: 0.25s;
}
.card:hover::after { opacity: 1; }

.card .head {
  display: flex; align-items: start; justify-content: space-between;
  gap: 12px;
}
.card h3 {
  font-size: 17px;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.4;
}
.card p.desc {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .meta {
  display: flex; align-items: center; gap: 12px;
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: auto;
}
.card .meta .lang { display: inline-flex; align-items: center; gap: 6px; }
.card .meta .lang .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.card .stars { display: inline-flex; align-items: center; gap: 4px; }

.note-card .cat {
  align-self: flex-start;
  font-size: 11px;
  color: var(--brand-ink);
  background: var(--brand-soft);
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.note-card h3 { font-size: 16px; }
.note-card .summary {
  font-size: 13px;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ----------  Filter chips  ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 24px;
}
.chip {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-soft);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.2s;
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip.on {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.searchbar {
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  margin: 0 0 24px;
  outline: none;
  transition: 0.2s;
  font-family: inherit;
}
.searchbar:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }

/* ----------  Page intro  ---------- */
.page-intro { padding: 64px 0 24px; }
.page-intro h1 {
  font-size: clamp(28px, 4vw, 40px);
  margin: 6px 0 8px;
  letter-spacing: -0.015em;
}
.page-intro .crumb {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--brand);
  font-weight: 700;
}
.page-intro p {
  color: var(--ink-soft);
  margin: 0;
  max-width: 640px;
}

/* ----------  Note viewer  ---------- */
.note-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 40px;
  padding: 40px 0 80px;
}
.note-toc {
  position: sticky;
  top: 88px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  font-size: 13px;
}
.note-toc .toc-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-mute);
  margin-bottom: 12px;
}
.note-toc a {
  display: block;
  color: var(--ink-soft);
  padding: 4px 10px;
  border-left: 2px solid var(--line);
  margin: 2px 0;
  line-height: 1.4;
}
.note-toc a.h2 { padding-left: 12px; }
.note-toc a.h3 { padding-left: 24px; font-size: 12.5px; }
.note-toc a:hover { color: var(--ink); text-decoration: none; border-left-color: var(--line-strong); }
.note-toc a.active { color: var(--brand); border-left-color: var(--brand); }

.note-content {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 48px clamp(20px, 5vw, 64px);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.note-meta {
  font-size: 13px;
  color: var(--ink-mute);
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 18px;
}
.note-meta .cat {
  color: var(--brand-ink);
  background: var(--brand-soft);
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.note-content h1 { font-size: clamp(26px, 3.4vw, 34px); letter-spacing: -0.015em; margin: 0 0 28px; line-height: 1.2; }
.note-content .markdown-body h1,
.note-content .markdown-body h2,
.note-content .markdown-body h3,
.note-content .markdown-body h4 {
  margin-top: 1.6em;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.note-content .markdown-body h2 {
  font-size: 22px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.note-content .markdown-body h3 { font-size: 18px; }
.note-content .markdown-body p { color: var(--ink); }
.note-content .markdown-body code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--brand-ink);
}
.note-content .markdown-body pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
}
.note-content .markdown-body pre code {
  background: none;
  padding: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}
.note-content .markdown-body blockquote {
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  margin: 16px 0;
  padding: 12px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--brand-ink);
}
.note-content .markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
.note-content .markdown-body th,
.note-content .markdown-body td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
}
.note-content .markdown-body th { background: var(--bg-soft); font-weight: 600; }
.note-content .markdown-body img {
  border-radius: var(--radius-sm);
  margin: 12px 0;
  border: 1px solid var(--line);
}

.note-iframe {
  width: 100%;
  border: none;
  min-height: 80vh;
  border-radius: var(--radius-sm);
  background: white;
}

.note-back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 18px;
}
.note-back:hover { color: var(--ink); text-decoration: none; }

/* ----------  Footer  ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 36px 0;
  margin-top: 60px;
  font-size: 13px;
  color: var(--ink-mute);
  text-align: center;
}
.site-footer a { color: var(--ink-soft); }

/* ----------  Empty state  ---------- */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-mute);
  font-size: 14px;
}

/* ----------  About page  ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
@media (max-width: 720px) {
  .about-grid { grid-template-columns: 1fr; }
}

/* ----------  Responsive  ---------- */
@media (max-width: 880px) {
  .hero { padding: 56px 0 32px; }
  .hero-inner { grid-template-columns: 1fr; gap: 32px; }
  .hero-side { justify-content: flex-start; }
  .avatar-card { transform: none; max-width: 100%; }
  .note-shell { grid-template-columns: 1fr; }
  .note-toc { display: none; }
}

@media (max-width: 560px) {
  .nav { gap: 12px; height: 56px; }
  .nav-links a { padding: 6px 10px; font-size: 13px; }
  section.block { padding: 40px 0; }
  .note-content { padding: 28px 18px; }
}

/* ----------  Print niceties (note pages)  ---------- */
@media print {
  .site-header, .site-footer, .note-toc, .note-back { display: none; }
  .note-content { border: none; padding: 0; box-shadow: none; }
}
