:root {
  --paper: #fafaf8;
  --mid: #4a4a4a;
  --ink: #1a1a1a;
  --soft: #f0f0ea;
  --soft2: #e6e6dd;
  --r: 28px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(26, 26, 26, 0.055) 1px, transparent 1px);
  background-size: 5px 5px;
  color: var(--ink);
  font-family: "Noto Sans Hebrew", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.75;
  font-weight: 400;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--ink);
}

img {
  max-width: 100%;
  height: auto;
}

/* ---------- 顶栏 ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(250, 250, 248, 0.95);
  border-bottom: 2px dashed rgba(26, 26, 26, 0.28);
  backdrop-filter: blur(4px);
}

.mark {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font-weight: 700;
  font-size: 19px;
  line-height: 1;
  border-radius: 14px 11px 16px 10px;
  box-shadow: 3px 3px 0 rgba(26, 26, 26, 0.22);
  transform: rotate(-3deg);
}

.mark img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.menu {
  position: relative;
}

.menu summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 16px;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 18px 15px 20px 14px;
  cursor: pointer;
  list-style: none;
  transform: rotate(0.6deg);
  transition: background-color 0.12s linear, color 0.12s linear;
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu summary:hover,
.menu[open] summary {
  background: var(--ink);
  color: var(--paper);
}

.menu menu {
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  width: min(80vw, 320px);
  margin: 0;
  padding: 8px;
  list-style: none;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 22px 18px 24px 20px;
  box-shadow: 7px 7px 0 rgba(26, 26, 26, 0.14);
}

.menu menu li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu menu a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 16px;
  text-decoration: none;
  color: var(--ink);
  transition: background-color 0.12s linear;
}

.menu menu a:hover {
  background: var(--soft);
}

.cta {
  margin-left: auto;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 20px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  color: var(--paper);
  background: var(--ink);
  border-radius: 16px 20px 14px 22px;
  transform: rotate(1.6deg);
  transition: transform 0.12s steps(2, end), background-color 0.12s linear;
}

.cta:hover {
  background: var(--mid);
  transform: rotate(-1.6deg) translateY(-1px);
}

/* ---------- 主区 ---------- */
.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px 16px 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 262px;
  gap: 40px;
  align-items: start;
}

.post {
  min-width: 0;
  overflow-wrap: anywhere;
}

.hero {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  text-align: left;
  padding: 7vh 0 3vh;
}

.hero h1 {
  margin: 0 0 14px;
  max-width: 18ch;
  font-size: clamp(30px, 6vw, 54px);
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.hero .lead {
  margin: 0;
  max-width: 44ch;
  color: var(--mid);
  font-size: 17px;
}

.hero-img {
  width: 100%;
  margin-top: 28px;
  border-radius: var(--r);
  filter: grayscale(0.18) contrast(1.05);
  transform: rotate(-0.8deg);
}

.post > div + div {
  margin-top: 54px;
  padding-top: 36px;
  border-top: 2px dashed rgba(26, 26, 26, 0.18);
}

.post div[id],
.post div {
  scroll-margin-top: 88px;
}

.post h2 {
  margin: 0 0 8px;
  font-size: clamp(23px, 3.6vw, 32px);
  line-height: 1.22;
  letter-spacing: -0.01em;
  font-weight: 700;
}

.post h3 {
  margin: 28px 0 8px;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 500;
}

.post p {
  margin: 0 0 1em;
}

.post h2 + p,
.post h3 + p {
  margin-top: 0;
}

.post p.subtitle,
.post .subtitle,
.post .subhead,
.post .desc,
.post .lead {
  color: var(--mid);
  font-size: 16px;
}

.post ul,
.post ol {
  margin: 0 0 1.1em;
  padding-left: 1.3em;
}

.post li {
  margin: 0 0 0.4em;
}

.post img {
  border-radius: var(--r);
}

.post figure {
  margin: 26px 0;
}

.post figcaption {
  margin-top: 8px;
  font-size: 16px;
  color: var(--mid);
}

.post blockquote {
  margin: 26px 0;
  padding: 16px 22px;
  background: var(--soft);
  border-radius: 22px 18px 24px 20px;
  transform: rotate(-0.4deg);
  color: var(--mid);
}

.post blockquote p:last-child {
  margin-bottom: 0;
}

.post table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 0 0 1.2em;
  font-size: 16px;
}

.post th,
.post td {
  padding: 8px 12px;
  border-bottom: 2px dashed rgba(26, 26, 26, 0.2);
  text-align: left;
  vertical-align: top;
}

.post code,
.post pre {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 16px;
}

.post pre {
  overflow-x: auto;
  padding: 14px 16px;
  background: var(--soft);
  border-radius: 18px;
}

.post a {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.post a:hover {
  background: var(--soft2);
}

/* ---------- 侧栏 ---------- */
.rail {
  position: sticky;
  top: 88px;
  padding: 20px 18px 22px;
  background: var(--soft);
  border-radius: var(--r);
  transform: rotate(0.5deg);
}

.rail h2 {
  margin: 0 0 2px;
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.rail .subtitle {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--mid);
}

.rail menu {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rail menu li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rail menu a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 4px 10px;
  font-size: 16px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 12px 10px 14px 9px;
  transition: background-color 0.12s linear, transform 0.12s steps(2, end);
}

.rail menu a:hover {
  background: var(--soft2);
  transform: rotate(-0.6deg);
}

/* ---------- 页脚 ---------- */
.foot {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 16px 34px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  border-top: 3px solid var(--ink);
  font-size: 16px;
}

.foot-mark {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
  border-radius: 11px 9px 13px 8px;
  transform: rotate(-4deg);
}

.foot-mark img {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 4px;
  min-width: 0;
}

.foot nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 4px 9px;
  color: var(--mid);
  text-decoration: none;
  border-radius: 10px;
  font-size: 16px;
  transition: color 0.12s linear, background-color 0.12s linear;
}

.foot nav a:hover {
  color: var(--ink);
  background: var(--soft);
}

.foot .copy {
  margin-left: auto;
  color: var(--mid);
  font-size: 16px;
}

/* ---------- 动效 ---------- */
@media (prefers-reduced-motion: no-preference) {
  .hero h1 {
    animation: ink-in 0.55s steps(4, end) both;
  }

  .mark {
    animation: tilt 9s steps(3, end) infinite;
  }

  .rail {
    animation: tilt-soft 11s steps(2, end) infinite;
  }
}

@keyframes ink-in {
  from {
    opacity: 0.2;
    transform: translateY(8px) rotate(-0.7deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes tilt {
  0%, 100% {
    transform: rotate(-3deg);
  }
  50% {
    transform: rotate(2.5deg);
  }
}

@keyframes tilt-soft {
  0%, 100% {
    transform: rotate(0.5deg);
  }
  50% {
    transform: rotate(-0.7deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- 窄屏 ---------- */
@media (max-width: 760px) {
  .wrap {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    padding: 4px 14px 40px;
  }

  .hero {
    min-height: 0;
    padding: 5vh 0 2vh;
  }

  .hero h1 {
    max-width: none;
  }

  .rail {
    position: static;
    order: 2;
  }

  .foot {
    gap: 10px;
    padding: 20px 14px 30px;
  }

  .foot .copy {
    margin-left: 0;
    width: 100%;
    text-align: center;
  }
}

button[aria-expanded]{min-width:44px;min-height:44px}
