:root {
  --bg: #eef2f3;
  --surface: rgba(255, 255, 255, 0.82);
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --code-bg: #0f172a;
  --code-fg: #e2e8f0;
  --mark-bg: #fef08a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image: url('assets/background.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(238, 242, 243, 0.35);
  pointer-events: none;
  z-index: 0;
}

.toolbar, .drawer, .drawer-overlay, main, footer {
  position: relative;
  z-index: 1;
}

.toolbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.toolbar-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1rem;
}
.brand {
  font-weight: 700; font-size: 1rem;
  color: var(--text); text-decoration: none;
  white-space: nowrap;
}
.search { flex: 1; display: flex; }
.search input {
  width: 100%; padding: .55rem .95rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: rgba(255,255,255,.85); font: inherit; outline: none;
  transition: border-color .15s, background .15s;
}
.search input:focus { border-color: var(--accent); background: #fff; }

.hamburger {
  width: 40px; height: 40px;
  display: inline-flex; flex-direction: column;
  justify-content: center; align-items: center; gap: 4px;
  border: 1px solid var(--border); border-radius: 8px;
  background: rgba(255,255,255,.85); cursor: pointer; padding: 0;
}
.hamburger span {
  display: block; width: 18px; height: 2px;
  background: var(--text); border-radius: 2px;
}
.hamburger:disabled { opacity: .4; cursor: not-allowed; }

.drawer {
  position: fixed; top: 0; right: -280px;
  width: 260px; height: 100%;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-left: 1px solid var(--border);
  padding: 4.5rem 1rem 1rem;
  transition: right .25s ease;
  z-index: 60;
  display: flex; flex-direction: column; gap: .25rem;
}
.drawer.open { right: 0; }
.drawer a {
  display: block; padding: .7rem .9rem;
  color: var(--text); text-decoration: none; border-radius: 8px;
}
.drawer a:hover { background: rgba(243,244,246,.8); }

.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
  z-index: 55;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

main {
  flex: 1; max-width: 1100px; width: 100%;
  margin: 0 auto; padding: 1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.card {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  overflow: hidden;
}
.card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.card a {
  display: block;
  color: inherit; text-decoration: none;
  padding: 0;
}
.card-body {
  padding: 1rem 1.1rem;
}

.card-thumb {
  width: 100%;
  aspect-ratio: 21 / 9;
  overflow: hidden;
  background: #f3f4f6;
  position: relative;
}
.card-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform .35s ease;
}
.card:hover .card-thumb img {
  transform: scale(1.04);
}

.card h2 {
  font-size: 1rem; margin: 0 0 .5rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
.card .excerpt {
  font-size: .86rem;
  color: #4b5563;
  margin: 0 0 .7rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta {
  display: flex; flex-wrap: wrap; gap: .35rem .9rem;
  font-size: .82rem; color: var(--muted);
}
.meta span { display: inline-flex; align-items: center; gap: .35rem; }
.meta svg { width: 14px; height: 14px; flex-shrink: 0; }
.meta .avatar {
  width: 18px; height: 18px; border-radius: 50%;
  object-fit: cover; display: inline-block;
}

.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: .3rem; margin: 1.5rem 0 .5rem; flex-wrap: wrap;
}
.page-btn {
  min-width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.85);
  border-radius: 8px; cursor: pointer;
  font: inherit; color: var(--text);
  transition: background .15s;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.page-btn:hover:not(.disabled) { background: #f3f4f6; }
.page-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.page-btn.disabled { opacity: .4; pointer-events: none; }
.ellipsis { padding: 0 .3rem; color: var(--muted); }

.article {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.1rem 2rem;
  max-width: 780px; margin: 0 auto;
  overflow: hidden;
}

.article-thumb {
  width: 100%;
  aspect-ratio: 21 / 9;
  overflow: hidden;
  background: #f3f4f6;
  margin: -1.25rem -1.1rem 1.25rem;
  border-radius: var(--radius) var(--radius) 0 0;
  position: relative;
}
.article-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.article h1 { font-size: 1.35rem; line-height: 1.35; margin: 0 0 .6rem; }
.article .content { margin-top: 1rem; overflow-x: hidden; min-width: 0; }
.article .content img { max-width: 100%; height: auto; border-radius: 8px; }
.article .content pre {
  background: var(--code-bg); color: var(--code-fg);
  padding: .9rem 1rem; border-radius: 8px;
  overflow-x: auto; font-size: .85rem;
}
.article .content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .88em;
}
.article .content :not(pre) > code {
  background: #f1f5f9; padding: .1em .35em; border-radius: 4px;
}
.article .content blockquote {
  border-left: 3px solid var(--border);
  margin: 1rem 0; padding: .2rem 1rem; color: var(--muted);
}
.article .content table {
  border-collapse: collapse; width: 100%; font-size: .9rem;
  display: block; overflow-x: auto;
}
.article .content th, .article .content td {
  border: 1px solid var(--border); padding: .4rem .6rem;
}
.article .content hr {
  border: none; border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}
.article .content a { color: var(--accent); }
.article .content mark {
  background: var(--mark-bg); color: inherit;
  padding: 0 .2em; border-radius: 3px;
}
.article .content sup,
.article .content sub { font-size: .75em; }

.article .content ul.task-list {
  list-style: none;
  padding-left: 0;
}
.article .content ul.task-list li.task {
  display: flex; align-items: flex-start; gap: .5rem;
}
.article .content ul.task-list input[type="checkbox"] {
  margin-top: .35rem;
  accent-color: var(--accent);
}

.article .content .katex { font-size: 1.02em; }
.article .content .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding: .75rem 0;
  margin: 1rem 0;
  -webkit-overflow-scrolling: touch;
}
.article .content .katex-display > .katex { white-space: nowrap; }
.article .content .katex-error {
  color: #dc2626;
  font-family: ui-monospace, monospace;
  font-size: .9em;
}

.article .content .mermaid {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 1.25rem 0;
  overflow-x: auto;
  text-align: center;
  font-size: .9rem;
  line-height: 1.4;
  -webkit-overflow-scrolling: touch;
}
.article .content .mermaid svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.article .content .mermaid:not([data-processed]) {
  color: transparent;
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 37%, #f3f4f6 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease infinite;
  min-height: 60px;
}
@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.profile {
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover; margin-bottom: .75rem;
}
.back {
  display: inline-block; margin-top: 1.5rem;
  color: var(--accent); text-decoration: none;
}

.empty, .error, .loading {
  text-align: center; color: var(--muted); padding: 3rem 1rem;
  background: rgba(255,255,255,.7);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
footer {
  text-align: center; padding: 1.25rem;
  color: #ffffff; font-size: .85rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  main {
    padding: 0;
    max-width: 100%;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 0;
    border-top: 1px solid var(--border);
  }

  .card {
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transform: none !important;
  }
  .card:hover {
    background: rgba(255, 255, 255, 0.92);
    box-shadow: none;
  }
  .card-body { padding: 1rem 1.1rem; }
  .card-thumb { aspect-ratio: 21 / 9; border-radius: 0; }

  .pagination {
    padding: 1rem;
    margin: 0;
  }

  .article {
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 1.25rem 1rem 2rem;
    max-width: 100%;
  }

  .article-thumb {
    margin: -1.25rem -1rem 1.25rem;
    width: calc(100% + 2rem);
    border-radius: 0;
    aspect-ratio: 21 / 9;
  }

  .article .content .katex { font-size: .92em; }
  .article .content .katex-display > .katex { font-size: .9em; }
  .article .content .katex-display > .katex > .katex-html { white-space: nowrap; }

  .article .content .mermaid {
    padding: .75rem .5rem;
    font-size: .82rem;
  }

  .empty, .error, .loading {
    border-radius: 0;
    margin: 0;
  }
}

.about {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 2rem;
}

.about-hero {
  text-align: center;
  padding: 2.25rem 1.25rem 1.75rem;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: fadeUp .5s ease both;
}

.avatar-ring {
  width: 96px;
  height: 96px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, #f0abfc, #a5b4fc, #7dd3fc);
  box-shadow: 0 8px 24px rgba(99, 102, 241, .25);
  animation: floaty 4s ease-in-out infinite;
}

.avatar-lg {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: #fff;
}

.about-hero h1 {
  margin: 0 0 .35rem;
  font-size: 1.6rem;
  letter-spacing: -.01em;
}

.grad {
  background: linear-gradient(135deg, #6366f1, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: .92rem;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .4rem;
}

.pill {
  font-size: .75rem;
  padding: .25rem .65rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, .1);
  color: #4338ca;
  border: 1px solid rgba(99, 102, 241, .18);
  transition: transform .15s ease, background .15s ease;
}

.pill:hover {
  transform: translateY(-1px);
  background: rgba(99, 102, 241, .18);
}

.views-line {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
}
.views-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  padding: .3rem .7rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, .06);
  color: var(--muted);
  border: 1px solid var(--border);
}
.views-badge svg { color: var(--accent); }

.about-block {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1.4rem;
  animation: fadeUp .5s ease both;
}

.about-block:nth-of-type(2) { animation-delay: .05s; }
.about-block:nth-of-type(3) { animation-delay: .10s; }
.about-block:nth-of-type(4) { animation-delay: .15s; }
.about-block:nth-of-type(5) { animation-delay: .20s; }

.about-block h2 {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1rem;
  margin: 0 0 .75rem;
}

.about-block h2 svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex-shrink: 0;
}

.about-block p { margin: 0 0 .6rem; }
.about-block p:last-child { margin-bottom: 0; }
.about-block p.muted {
  color: var(--muted);
  font-size: .88rem;
}

.about-list {
  margin: 0 0 .6rem;
  padding-left: 1.1rem;
  color: #374151;
}

.about-list li { margin-bottom: .25rem; }

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .6rem;
}

.contact {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .2rem;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  text-decoration: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.contact:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.95);
}

.contact svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
  margin-bottom: .25rem;
}

.contact-title {
  font-weight: 600;
  font-size: .9rem;
}

.contact-sub {
  font-size: .78rem;
  color: var(--muted);
}

.back-home {
  align-self: center;
  margin-top: .5rem;
  color: var(--accent);
  text-decoration: none;
  font-size: .9rem;
  transition: transform .15s ease;
}

.back-home:hover { transform: translateX(-3px); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

@media (max-width: 640px) {
  .about {
    padding: 0;
    gap: 0;
  }

  .about-hero,
  .about-block {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .about-hero { padding: 1.75rem 1.25rem 1.5rem; }
  .about-block { border-top: none; }

  .contact-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .about-hero,
  .about-block,
  .avatar-ring {
    animation: none !important;
  }
}