@layer reset, base, content, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { color-scheme: light; }
  img, picture, video, canvas, svg { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; }
}

@layer base {
  :root {
    --paper: oklch(98.3% 0.006 226);
    --ink: oklch(26% 0.018 244);
    --muted: oklch(53% 0.022 240);
    --faint: oklch(89% 0.012 229);
    --blue: oklch(52% 0.082 233);
    --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
    --sans: "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
    --mono: "SFMono-Regular", "Cascadia Mono", "Noto Sans Mono CJK SC", monospace;
  }

  body {
    min-width: 320px;
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    text-rendering: optimizeLegibility;
  }

  a {
    color: inherit;
    -webkit-tap-highlight-color: transparent;
  }

  a:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 4px;
  }

  .site-header,
  .main-content,
  .site-footer {
    width: min(720px, calc(100% - 48px));
    margin-inline: auto;
  }

  .site-header { padding-top: 64px; }

  .site-title {
    display: inline-block;
    color: var(--ink);
    font: 600 clamp(1.72rem, 3.4vw, 2.55rem) / 1.12 var(--serif);
    letter-spacing: 0.015em;
    text-decoration: none;
    text-wrap: balance;
  }

  .site-subtitle {
    max-width: 620px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.91rem;
    line-height: 1.8;
    text-wrap: pretty;
  }

  .main-content { padding: 46px 0 96px; }

  .site-footer {
    padding: 0 0 48px;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.75;
  }

  .site-footer strong { color: var(--ink); font-weight: 600; }
}

@layer content {
  .entry { padding-bottom: 112px; }
  .entry:last-child { padding-bottom: 0; }

  .entry-title {
    color: var(--ink);
    font: 600 clamp(1.42rem, 2.65vw, 1.9rem) / 1.42 var(--serif);
    letter-spacing: 0.01em;
    text-wrap: balance;
  }

  .entry-title a {
    text-decoration: none;
  }

  .entry-title a:hover { color: var(--blue); }

  .entry-body {
    margin-top: 34px;
    font: 400 1rem / 2 var(--serif);
    overflow-wrap: anywhere;
  }

  .entry-body p {
    margin-bottom: 1.5em;
    text-wrap: pretty;
  }

  .entry-body h1,
  .entry-body h2,
  .entry-body h3,
  .entry-body h4 {
    margin: 2.25em 0 0.82em;
    font-family: var(--serif);
    font-weight: 600;
    line-height: 1.5;
    text-wrap: balance;
  }

  .entry-body h1 { font-size: 1.5rem; }
  .entry-body h2 { font-size: 1.36rem; }
  .entry-body h3 { font-size: 1.24rem; }
  .entry-body h4 { font-size: 1.1rem; }

  .entry-body blockquote {
    margin: 2em 0;
    padding-left: 1.2em;
    border-left: 2px solid var(--blue);
    color: var(--muted);
  }

  .entry-body blockquote > :last-child { margin-bottom: 0; }

  .entry-body ul,
  .entry-body ol {
    margin: 0 0 1.5em;
    padding-left: 1.5em;
  }

  .entry-body li + li { margin-top: 0.35em; }

  .entry-body a {
    color: var(--blue);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
  }

  .entry-body hr {
    height: 2.4em;
    border: 0;
  }

  .entry-body img {
    width: auto;
    height: auto;
    margin: 2em auto;
  }

  .entry-body figure { margin: 2em 0; }
  .entry-body figure img { margin: 0 auto; }

  .entry-body figcaption {
    margin-top: 0.8em;
    color: var(--muted);
    font: 400 0.78rem / 1.7 var(--sans);
    text-align: center;
  }

  .entry-body :not(pre) > code {
    padding: 0.12em 0.32em;
    background: var(--faint);
    font: 0.88em / 1.5 var(--mono);
  }

  .entry-body pre {
    margin: 2em 0;
    padding: 1.15em 1.25em;
    overflow-x: auto;
    background: var(--faint);
    font: 0.82rem / 1.75 var(--mono);
  }

  .entry-body table {
    width: 100%;
    margin: 2em 0;
    border-collapse: collapse;
    font: 0.86rem / 1.65 var(--sans);
  }

  .entry-body th,
  .entry-body td {
    padding: 0.65em 0.75em;
    border-bottom: 1px solid var(--faint);
    text-align: left;
    vertical-align: top;
  }

  .entry-signoff {
    margin-top: 22px;
    color: var(--muted);
    font: 500 0.73rem / 1.5 var(--mono);
    letter-spacing: 0.02em;
  }

  .entry-single { padding-bottom: 0; }

  .pagination {
    display: flex;
    min-height: 44px;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    font: 500 0.74rem / 1.5 var(--mono);
  }

  .pagination a {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    text-decoration: none;
  }

  .pagination a:hover { color: var(--blue); }
}

@layer responsive {
  @media (max-width: 760px) {
    .site-header,
    .main-content,
    .site-footer { width: min(720px, calc(100% - 32px)); }

    .site-header { padding-top: 38px; }
    .main-content { padding-top: 38px; padding-bottom: 80px; }
    .entry { padding-bottom: 80px; }
    .entry-title { font-size: clamp(1.4rem, 6.4vw, 1.82rem); }
    .entry-body { margin-top: 28px; font-size: 0.98rem; line-height: 1.95; }
    .site-footer { padding-bottom: 36px; }
  }

  @media print {
    :root { --paper: white; --ink: black; }
    .site-header, .site-footer, .pagination { display: none; }
    .main-content { width: 100%; padding: 0; }
    .entry { break-after: page; }
  }
}
