:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-soft: #edf3fb;
  --text: #162033;
  --muted: #657289;
  --line: rgba(40, 58, 92, 0.12);
  --brand: #1f7ae0;
  --brand-strong: #1257a8;
  --cyan: #1db7c8;
  --amber: #d28a16;
  --green: #28a46b;
  --rose: #d65d7d;
  --shadow: 0 18px 45px rgba(37, 58, 92, 0.12);
  --max: 1180px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101624;
  --surface: rgba(22, 30, 48, 0.84);
  --surface-solid: #161e30;
  --surface-soft: #1d293e;
  --text: #eef4ff;
  --muted: #9aa7bc;
  --line: rgba(220, 230, 255, 0.13);
  --brand: #68a8ff;
  --brand-strong: #8fc3ff;
  --cyan: #55d5df;
  --amber: #f1b458;
  --green: #61d59a;
  --rose: #f58aaa;
  --shadow: 0 22px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top left, rgba(31, 122, 224, 0.12), transparent 30rem),
    linear-gradient(180deg, var(--bg), var(--bg));
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Microsoft YaHei",
    sans-serif;
  line-height: 1.65;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
}

.fireworks {
  position: fixed;
  inset: 0;
  z-index: 9999;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(100% - 32px, var(--max));
  height: 66px;
  margin: 12px auto 0;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(24, 42, 70, 0.08);
  backdrop-filter: blur(18px);
}

.brand,
.nav-links,
.header-actions,
.hero-meta,
.ticker,
.post-meta,
.post-tags,
.profile-stats,
.panel-heading,
.search,
.site-footer {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  min-width: max-content;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--cyan));
  color: #fff;
  font-weight: 900;
}

.brand-text {
  letter-spacing: 0;
}

.nav-links {
  gap: 6px;
}

.nav-links a {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.nav-links a:hover,
.nav-links a.is-active {
  background: var(--surface-soft);
  color: var(--brand-strong);
}

.header-actions {
  gap: 8px;
}

.icon-btn,
.back-top {
  position: relative;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.icon-btn svg,
.back-top svg,
.search svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-btn:hover,
.back-top:hover {
  border-color: rgba(31, 122, 224, 0.36);
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.icon-btn::after,
.back-top::after {
  position: absolute;
  right: 0;
  bottom: -34px;
  z-index: 30;
  width: max-content;
  max-width: 140px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #141a28;
  color: #fff;
  content: attr(data-tooltip);
  font-size: 12px;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.icon-btn:hover::after,
.icon-btn:focus-visible::after,
.back-top:hover::after,
.back-top:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.menu-toggle {
  display: none;
}

.hero {
  width: min(100% - 32px, var(--max));
  min-height: 350px;
  margin: 22px auto 0;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(8, 16, 31, 0.82), rgba(8, 16, 31, 0.34)),
    url("assets/hero-tech.svg") center / cover;
  color: #fff;
  box-shadow: var(--shadow);
}

.post-hero {
  position: relative;
  width: min(100% - 32px, var(--max));
  min-height: 420px;
  margin: 22px auto 0;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(9, 15, 28, 0.28), rgba(9, 15, 28, 0.78)),
    url("assets/cover-algebra.svg") center / cover;
  color: #fff;
  box-shadow: var(--shadow);
}

.post-hero-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: end;
  min-height: 420px;
  padding: clamp(34px, 6vw, 76px);
}

.article-badges,
.article-meta-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.article-badges span {
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 800;
}

.post-hero h1 {
  max-width: 12em;
  margin: 18px 0 0;
  font-size: clamp(34px, 6vw, 68px);
  line-height: 1.08;
  letter-spacing: 0;
}

.post-hero h1 span {
  display: block;
}

.article-meta-line {
  margin-top: 18px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 14px;
  font-weight: 700;
}

.article-meta-line span {
  position: relative;
}

.article-meta-line span + span::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin: 0 10px 2px 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.48);
}

.wave {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 42px;
  background:
    radial-gradient(80px 30px at 10% 100%, var(--bg) 98%, transparent),
    radial-gradient(120px 38px at 36% 100%, var(--bg) 98%, transparent),
    radial-gradient(96px 34px at 62% 100%, var(--bg) 98%, transparent),
    radial-gradient(130px 42px at 88% 100%, var(--bg) 98%, transparent);
  opacity: 0.98;
}

.hero-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 350px;
  max-width: 700px;
  padding: clamp(32px, 7vw, 72px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 12em;
  margin: 0;
  font-size: clamp(36px, 7vw, 74px);
  line-height: 1.06;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 36rem;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(16px, 2vw, 20px);
}

.hero-meta {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.hero-meta span {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  font-weight: 700;
}

.ticker {
  gap: 14px;
  width: min(100% - 32px, var(--max));
  margin: 18px auto 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(38, 52, 82, 0.08);
  overflow-x: auto;
  white-space: nowrap;
}

.ticker-label {
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(31, 122, 224, 0.12);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
}

.ticker a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.ticker a:hover {
  color: var(--brand-strong);
}

.page-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
  width: min(100% - 32px, var(--max));
  margin: 22px auto 0;
}

.sidebar {
  display: grid;
  align-self: start;
  gap: 18px;
  position: sticky;
  top: 96px;
}

.profile-card,
.side-panel,
.content,
.archive-inner {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(37, 58, 92, 0.08);
  backdrop-filter: blur(16px);
}

.profile-card {
  padding: 24px;
  text-align: center;
}

.avatar {
  width: 104px;
  height: 104px;
  margin: 0 auto 14px;
  border: 4px solid var(--surface-solid);
  border-radius: 50%;
  box-shadow: 0 10px 24px rgba(27, 43, 68, 0.18);
}

.profile-card h2,
.side-panel h2,
.section-head h2,
.archive h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.2;
}

.profile-card h2 {
  font-size: 22px;
}

.profile-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.profile-stats {
  justify-content: space-between;
  gap: 8px;
  margin-top: 18px;
}

.profile-stats span {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
  padding: 10px 6px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.profile-stats strong {
  color: var(--text);
  font-size: 13px;
}

.side-panel {
  padding: 18px;
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  font-size: 18px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  padding: 7px 10px;
}

.tag:hover,
.tag.is-active {
  border-color: rgba(31, 122, 224, 0.32);
  background: rgba(31, 122, 224, 0.12);
  color: var(--brand-strong);
}

.project-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.project-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.project-list a:hover {
  color: var(--brand-strong);
}

.dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.dot-cyan {
  background: var(--cyan);
}

.dot-amber {
  background: var(--amber);
}

.dot-green {
  background: var(--green);
}

.content {
  padding: clamp(18px, 3vw, 28px);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h2,
.archive h2 {
  font-size: clamp(24px, 3vw, 32px);
}

.search {
  gap: 8px;
  width: min(100%, 270px);
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--muted);
}

.search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.article-list {
  display: grid;
  gap: 18px;
}

.post-card {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 178px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  overflow: hidden;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.post-card:hover {
  border-color: rgba(31, 122, 224, 0.3);
  box-shadow: 0 16px 38px rgba(30, 47, 75, 0.12);
  transform: translateY(-2px);
}

.post-cover {
  min-width: 0;
  background: var(--surface-soft);
}

.post-cover img {
  width: 100%;
  height: 100%;
  min-height: 178px;
  object-fit: cover;
}

.post-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 20px;
}

.post-meta {
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.post-card h3 {
  margin: 0;
  font-size: clamp(20px, 2.5vw, 26px);
  letter-spacing: 0;
  line-height: 1.25;
}

.post-card h3 a:hover {
  color: var(--brand-strong);
}

.post-card p {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 15px;
}

.post-tags {
  flex-wrap: wrap;
  gap: 8px;
}

.post-tags span {
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(31, 122, 224, 0.1);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
}

.empty-state {
  display: none;
  margin: 18px 0 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state.is-visible {
  display: block;
}

.archive {
  width: min(100% - 32px, var(--max));
  margin: 22px auto 0;
}

.archive-inner {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  padding: clamp(20px, 4vw, 34px);
}

.timeline {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-width: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.timeline li:last-child {
  border-bottom: 0;
}

.timeline time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.timeline a {
  overflow-wrap: anywhere;
  font-weight: 800;
}

.timeline a:hover {
  color: var(--brand-strong);
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  width: min(100% - 32px, var(--max));
  margin: 22px auto 0;
}

.article-card {
  min-width: 0;
  padding: clamp(22px, 4vw, 46px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(37, 58, 92, 0.08);
}

.article-card .lead {
  margin: 0 0 26px;
  padding: 18px 20px;
  border-left: 4px solid var(--brand);
  border-radius: 0 8px 8px 0;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 17px;
}

.article-card section {
  margin-top: 34px;
}

.article-card h2 {
  margin: 0 0 14px;
  padding-top: 12px;
  color: var(--text);
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: 0;
  line-height: 1.25;
}

.article-card h2::before {
  content: "#";
  margin-right: 8px;
  color: var(--brand);
}

.article-card h3 {
  margin: 22px 0 10px;
  color: var(--text);
  font-size: 22px;
  letter-spacing: 0;
}

.article-card p,
.article-card li {
  color: var(--muted);
  font-size: 16px;
}

.article-card p {
  margin: 0 0 14px;
}

.article-card ul {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding-left: 22px;
}

.article-card code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--brand-strong);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.article-card pre {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #dbeafe;
  overflow-x: auto;
}

.article-card pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.definition-box,
.article-note,
.article-copyright {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.definition-box strong,
.article-copyright strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.article-note h2 {
  padding-top: 0;
}

.article-copyright {
  margin-top: 36px;
}

.article-copyright p {
  margin-bottom: 0;
  font-size: 14px;
}

.post-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.post-pager a {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.post-pager a:hover {
  border-color: rgba(31, 122, 224, 0.32);
  color: var(--brand-strong);
}

.article-aside {
  display: grid;
  align-self: start;
  gap: 18px;
  position: sticky;
  top: 96px;
}

.profile-card.compact {
  padding: 20px;
}

.profile-card.compact .avatar {
  width: 82px;
  height: 82px;
}

.announcement {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.toc-panel {
  max-height: calc(100vh - 116px);
  overflow: auto;
}

.toc {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc a {
  display: block;
  padding: 7px 8px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.toc a:hover {
  background: var(--surface-soft);
  color: var(--brand-strong);
}

.back-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

.back-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.site-footer {
  justify-content: center;
  gap: 12px;
  min-height: 86px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer span + span::before {
  content: "/";
  margin-right: 12px;
  color: var(--line);
}

@media (max-width: 900px) {
  .site-header {
    width: min(100% - 24px, var(--max));
  }

  .menu-toggle {
    display: grid;
  }

  .nav-links {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: min(220px, calc(100vw - 24px));
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-solid);
    box-shadow: var(--shadow);
  }

  .nav-links.is-open {
    display: flex;
  }

  .nav-links a {
    width: 100%;
  }

  .hero,
  .post-hero,
  .ticker,
  .page-shell,
  .archive,
  .article-layout {
    width: min(100% - 24px, var(--max));
  }

  .page-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-card {
    grid-row: span 2;
  }

  .archive-inner {
    grid-template-columns: 1fr;
  }

  .article-layout {
    grid-template-columns: 1fr;
  }

  .article-aside {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toc-panel {
    grid-column: 1 / -1;
    max-height: none;
  }
}

@media (max-width: 640px) {
  .site-header {
    height: 58px;
    padding: 0 10px;
  }

  .brand-text {
    max-width: 125px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hero {
    min-height: 300px;
  }

  .post-hero {
    min-height: 340px;
  }

  .hero-content {
    min-height: 300px;
    padding: 28px 20px;
  }

  .post-hero-content {
    min-height: 340px;
    padding: 28px 20px 46px;
  }

  .hero h1 {
    font-size: clamp(32px, 11vw, 46px);
  }

  .post-hero h1 {
    font-size: clamp(30px, 8vw, 40px);
    line-height: 1.14;
  }

  .article-meta-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .article-meta-line span + span::before {
    content: none;
  }

  .ticker {
    flex-wrap: wrap;
    overflow-x: visible;
    white-space: normal;
  }

  .ticker a {
    overflow-wrap: anywhere;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    width: 100%;
  }

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

  .article-aside {
    grid-template-columns: 1fr;
  }

  .profile-card {
    grid-row: auto;
  }

  .post-card {
    grid-template-columns: 1fr;
  }

  .post-cover img {
    aspect-ratio: 16 / 9;
    min-height: 0;
  }

  .timeline li {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .post-pager {
    grid-template-columns: 1fr;
  }

  .site-footer {
    flex-direction: column;
    gap: 4px;
  }

  .site-footer span + span::before {
    content: "";
    margin-right: 0;
  }
}
