:root {
  --bg: #f7f8fb;
  --panel: #eef3f9;
  --line: rgba(15, 23, 42, 0.1);
  --text: #1e293b;
  --text-body: #334155;
  --heading: #0f172a;
  --muted: #64748b;
  --accent: #1d6fdc;
  --accent-hover: #1558b8;
  --link: #1d6fdc;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.8;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--accent-hover);
}

.page {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.hero {
  max-width: 54rem;
  padding: 2.6rem 0 1.2rem;
}

.breadcrumb {
  margin: 0 0 1rem;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  line-height: 1.45;
}

.breadcrumb li {
  display: inline-flex;
  align-items: center;
  margin: 0;
  color: var(--muted);
}

.breadcrumb li + li::before {
  content: "/";
  margin: 0 0.45rem;
  color: var(--muted);
  opacity: 0.72;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

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

.breadcrumb [aria-current="page"] {
  color: var(--text-body);
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: 13.5rem minmax(0, 1fr);
  gap: 2.5rem;
  align-items: stretch;
  padding-bottom: 2rem;
}

.article-body {
  max-width: 54rem;
}

section {
  scroll-margin-top: 1.5rem;
}

h1 {
  margin: 0 0 0.9rem;
  font-size: clamp(2rem, 4.6vw, 3rem);
  font-weight: 900;
  line-height: 1.24;
  letter-spacing: -0.012em;
  color: var(--heading);
}

.meta {
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.meta time {
  color: #475569;
}

p {
  margin: 0 0 1.1rem;
  color: var(--text-body);
}

h2 {
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
  font-size: 1.35rem;
  color: var(--heading);
}

h3 {
  margin: 1.6rem 0 0.75rem;
  font-size: 1.1rem;
  color: var(--heading);
}

ul {
  margin: 0 0 1.1rem;
  padding-left: 1.25rem;
  color: var(--text-body);
}

li {
  margin: 0.45rem 0;
}

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

.toc-aside {
  position: relative;
}

.toc {
  position: sticky;
  top: 1.25rem;
  z-index: 10;
  margin: 0;
  padding: 0.85rem 0 0.85rem 0.75rem;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-left: 2px solid var(--line);
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, 0.2) transparent;
}

.toc::-webkit-scrollbar {
  width: 4px;
}

.toc::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.2);
  border-radius: 4px;
}

.toc-title {
  margin: 0 0 0.65rem;
  padding-left: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-body);
  text-decoration: none;
}

.toc a:hover,
.toc a.is-active {
  color: var(--accent);
  background: var(--panel);
}

.toc a.is-active {
  font-weight: 600;
  border-left: 2px solid var(--accent);
  margin-left: -2px;
  padding-left: calc(0.5rem + 2px);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .toc-aside {
    order: -1;
    margin-bottom: 1.5rem;
  }

  .toc {
    position: static;
    max-height: none;
    overflow-y: visible;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 12px;
    background: linear-gradient(145deg, #ffffff, var(--panel));
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  }

  .toc a.is-active {
    border-left: none;
    margin-left: 0;
    padding-left: 0.5rem;
  }

  .toc-title {
    font-size: 0.95rem;
    letter-spacing: 0;
    text-transform: none;
    color: var(--heading);
  }

  .toc a {
    font-size: 0.95rem;
  }
}

.tip {
  margin: 1.2rem 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 0.95rem 1rem;
  color: var(--text-body);
}

.footer {
  margin-top: 2.6rem;
  padding: 1.2rem 0 2.2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}

.to-top {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 40;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12), 0 2px 4px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(0.75rem);
  transition:
    opacity 0.28s ease,
    transform 0.28s ease,
    visibility 0.28s ease,
    background-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.to-top:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(29, 111, 220, 0.35);
}

.to-top:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

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

.to-top__icon {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .to-top {
    transition: none;
  }

  .to-top.is-visible {
    transform: none;
  }
}
