* {
  box-sizing: border-box;
}

html {
  margin: 0;
  padding: 0;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  min-width: 320px;
  overflow-x: hidden;

  background: var(--bg);
  color: var(--text);

  font-family:
    "Noto Serif SC",
    "Songti SC",
    "STSong",
    Georgia,
    serif;

  transition:
    background-color 0.45s ease,
    color 0.45s ease;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

.page {
  position: relative;
  z-index: 2;
  width: min(calc(100% - 48px), var(--content-width));
  margin: 0 auto;
}

/* Header */
.site-header {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  text-decoration: none;

  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 25px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.brand-main {
  color: var(--text);
}

.brand-accent {
  color: var(--main);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.site-nav a {
  position: relative;
  color: var(--weak);
  text-decoration: none;

  font-size: 14px;
  letter-spacing: 0.08em;

  transition: color 0.25s ease;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -7px;
  height: 1px;

  background: var(--main);

  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.25s ease;
}

.site-nav a:hover {
  color: var(--main);
}

.site-nav a:hover::after {
  transform: scaleX(1);
}

/* Hero */
.hero {
  min-height: 72vh;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  text-align: center;
  padding: 56px 0 88px;
}

.seal {
  position: relative;

  width: 82px;
  height: 82px;

  display: grid;
  place-items: center;

  border: 2px solid var(--main);
  color: var(--main);

  font-size: 36px;
  line-height: 1;

  margin-bottom: 34px;

  background: rgba(255, 252, 251, 0.28);
}

.seal::before,
.seal::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  background: var(--main);
}

.seal::before {
  left: 7px;
  top: 7px;
}

.seal::after {
  right: 7px;
  bottom: 7px;
}

.hero-title {
  margin: 0;

  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(42px, 8vw, 72px);
  line-height: 1.08;
  font-weight: 600;

  letter-spacing: clamp(0.12em, 1.2vw, 0.28em);
  color: var(--text);
}

.hero-subtitle {
  margin: 24px 0 0;
  color: var(--weak);

  font-size: clamp(20px, 3vw, 26px);
  line-height: 1.7;
  letter-spacing: 0.08em;
}

.hero-desc {
  margin: 18px 0 0;
  color: var(--weak);

  font-size: 14px;
  line-height: 1.9;
  letter-spacing: 0.15em;
}

.hero-note {
  max-width: 620px;
  margin: 34px 0 0;

  color: var(--weak);
  font-size: 14px;
  line-height: 2;
  opacity: 0.92;
}

.hero-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 148px;
  margin-top: 38px;
  padding: 13px 28px;

  border: 1px solid var(--main);
  border-radius: 999px;

  background: var(--main);
  color: #fff;
  text-decoration: none;

  font-size: 14px;
  letter-spacing: 0.12em;

  box-shadow: 0 10px 24px rgba(178, 108, 112, 0.18);

  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease;
}

.hero-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(178, 108, 112, 0.23);
}

/* Sections */
.section-divider {
  width: 100%;
  height: 1px;

  background:
    linear-gradient(
      to right,
      transparent,
      var(--line) 18%,
      var(--line) 82%,
      transparent
    );
}

.section {
  padding: 82px 0;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 34px;
}

.section-kicker {
  margin: 0 0 8px;

  color: var(--main);

  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;

  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.section-title {
  margin: 0;

  font-size: clamp(28px, 4vw, 34px);
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.section-description {
  margin: 0;
  color: var(--weak);

  font-size: 13px;
  line-height: 1.8;
}

/* Posts */
.posts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.post-card {
  min-width: 0;
  padding: 30px;

  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;

  box-shadow: var(--shadow);

  transition:
    transform 0.28s ease,
    box-shadow 0.28s ease,
    border-color 0.28s ease;
}

.post-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow: 0 18px 42px rgba(88, 55, 55, 0.11);
}

.post-date {
  margin: 0;

  color: var(--weak);

  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.13em;
}

.post-tag {
  display: inline-flex;
  align-items: center;

  margin-top: 17px;
  padding: 5px 9px;

  border-radius: 999px;

  background: var(--float);
  color: var(--main);

  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.08em;
}

.post-title {
  margin: 18px 0 0;

  font-size: 20px;
  line-height: 1.6;
  font-weight: 500;
}

.post-excerpt {
  margin: 13px 0 0;

  color: var(--weak);

  font-size: 14px;
  line-height: 1.95;
}

.post-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  margin-top: 22px;

  color: var(--main);
  text-decoration: none;

  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  letter-spacing: 0.1em;

  transition: gap 0.2s ease;
}

.post-link:hover {
  gap: 13px;
}

/* About */
.about-box {
  position: relative;
  overflow: hidden;

  padding: 52px 48px;

  border-radius: 28px;

  background: linear-gradient(
    135deg,
    var(--float),
    var(--card)
  );

  border: 1px solid var(--line);
}

.about-label {
  margin: 0;
  color: var(--main);

  font-size: 12px;
  letter-spacing: 0.18em;
}

.about-title {
  margin: 12px 0 0;

  font-size: 29px;
  line-height: 1.5;
  font-weight: 500;
}

.about-text {
  max-width: 700px;
  margin: 20px 0 0;

  color: var(--weak);

  font-size: 14px;
  line-height: 2.15;
}

/* Footer */
.site-footer {
  padding: 22px 0 42px;

  text-align: center;

  color: var(--weak);

  font-size: 12px;
  line-height: 1.8;
  letter-spacing: 0.08em;
}

.footer-mark {
  margin-bottom: 8px;

  color: var(--main);

  font-family: "Helvetica Neue", Arial, sans-serif;

  font-size: 11px;
  letter-spacing: 0.18em;
}

.footer-email {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--weak);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-email:hover {
  color: var(--main);
}

/* Article pages */
.article-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.article-content {
  flex: 1;
  width: min(100%, 820px);
  margin: 34px auto 72px;
  padding: clamp(26px, 6vw, 64px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.article-content > h1 {
  margin: 24px 0 38px;
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.45;
  font-weight: 500;
}

.article-back {
  color: var(--main);
  text-decoration: none;
  font-size: 13px;
}

.article-back:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.article-body {
  color: var(--text);
  font-size: 16px;
  line-height: 2;
  overflow-wrap: anywhere;
}

.article-body h2,
.article-body h3,
.article-body h4 {
  margin: 2em 0 0.8em;
  font-weight: 500;
  line-height: 1.5;
}

.article-body h2 {
  padding-bottom: 0.45em;
  border-bottom: 1px solid var(--line);
  font-size: 25px;
}

.article-body h3 { font-size: 21px; }
.article-body h4 { font-size: 18px; }
.article-body p { margin: 1em 0; }
.article-body strong { color: var(--main); font-weight: 600; }

.article-body blockquote {
  margin: 1.5em 0;
  padding: 0.2em 0 0.2em 1.2em;
  border-left: 3px solid var(--accent);
  color: var(--weak);
}

.article-body hr {
  margin: 2em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.article-formula {
  overflow-x: auto;
  padding: 18px 22px;
  background: var(--float);
  border-radius: 12px;
  font: 15px/1.9 "Cascadia Code", Consolas, monospace;
  white-space: pre-wrap;
}

.article-back-bottom { display: inline-block; margin-top: 40px; }

.notes-page-heading {
  padding-bottom: 36px;
}

.notes-page-heading .section-title {
  margin-top: 14px;
}

.notes-page-heading .section-description {
  margin-top: 16px;
}

.notes-list {
  padding-top: 0;
}

.note-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: center;
  gap: 20px;
  padding: 24px 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: color 0.2s ease, padding 0.2s ease;
}

.note-row:first-child {
  border-top: 1px solid var(--line);
}

.note-row:hover {
  padding-right: 0;
  padding-left: 10px;
  color: var(--main);
}

.note-row-type {
  color: var(--weak);
  font-size: 12px;
}

.note-row-title {
  font-size: 18px;
}

.note-row-arrow {
  color: var(--main);
  text-align: right;
}

.subject-groups { padding-bottom: 48px; }
.subject-group { margin: 0 0 42px; }
.subject-title {
  margin: 0 0 14px;
  color: var(--main);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.about-page-content {
  width: min(100%, 820px);
  margin: 30px auto 60px;
}

.about-page-content .about-box { margin-top: 18px; }

/* Keep a flex column so more fixed quick actions can be added later. */
.floating-actions {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.floating-action {
  width: 54px;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--main);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.floating-action:hover { transform: translateY(-3px); background: var(--float); }
.floating-action > span:first-child { font: 21px/1 Arial, sans-serif; }
.floating-action-label { font-size: 9px; line-height: 1.2; }

.note-data {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(100px, 1fr);
  border-top: 1px solid var(--line);
}

.note-data dt, .note-data dd {
  margin: 0;
  padding: 18px 8px;
  border-bottom: 1px solid var(--line);
}

.note-data dt { color: var(--weak); }
.note-data dd { text-align: right; }
.article-source-note { margin-top: 24px; color: var(--weak); font-size: 13px; line-height: 1.8; }

@media (max-width: 640px) {
  .article-content {
    margin: 18px 0 48px;
    padding: 26px 22px;
    border-radius: 18px;
  }

  .article-body { font-size: 15px; }

  .note-row {
    grid-template-columns: 1fr 24px;
    gap: 7px 12px;
    padding: 20px 2px;
  }

  .note-row-title { font-size: 17px; }
}

/* Snow */
.snow {
  position: fixed;
  inset: 0;

  overflow: hidden;
  pointer-events: none;

  z-index: 1;
}

.snow span {
  position: absolute;
  top: -8vh;

  color: var(--accent);
  opacity: 0.4;

  user-select: none;

  animation: snowfall linear infinite;
}

@keyframes snowfall {
  0% {
    transform: translate3d(0, -10vh, 0);
  }

  100% {
    transform: translate3d(30px, 120vh, 0);
  }
}

.snow span:nth-child(1) {
  left: 8%;
  font-size: 13px;
  animation-duration: 13s;
  animation-delay: -4s;
}

.snow span:nth-child(2) {
  left: 22%;
  font-size: 10px;
  animation-duration: 18s;
  animation-delay: -9s;
}

.snow span:nth-child(3) {
  left: 39%;
  font-size: 16px;
  animation-duration: 15s;
  animation-delay: -2s;
}

.snow span:nth-child(4) {
  left: 57%;
  font-size: 11px;
  animation-duration: 21s;
  animation-delay: -12s;
}

.snow span:nth-child(5) {
  left: 76%;
  font-size: 15px;
  animation-duration: 17s;
  animation-delay: -7s;
}

.snow span:nth-child(6) {
  left: 91%;
  font-size: 10px;
  animation-duration: 20s;
  animation-delay: -14s;
}

.theme-night .snow span {
  opacity: 0.5;
}

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

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* Tablet */
@media (max-width: 860px) {
  .posts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero {
    min-height: 64vh;
  }
}

/* Mobile */
@media (max-width: 640px) {
  .page {
    width: min(
      calc(100% - 32px),
      var(--content-width)
    );
  }

  .site-header {
    min-height: 76px;
  }

  .site-nav {
    gap: 16px;
  }

  .site-nav a {
    font-size: 12px;
  }

  .hero {
    min-height: 68vh;
    padding: 42px 0 66px;
  }

  .seal {
    width: 70px;
    height: 70px;
    margin-bottom: 28px;
    font-size: 31px;
  }

  .hero-subtitle {
    margin-top: 20px;
  }

  .hero-desc {
    letter-spacing: 0.08em;
  }

  .hero-note {
    font-size: 13px;
  }

  .section {
    padding: 58px 0;
  }

  .section-heading {
    display: block;
  }

  .section-description {
    margin-top: 12px;
  }

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

  .post-card {
    padding: 26px;
  }

  .about-box {
    padding: 34px 26px;
  }

  .floating-actions { right: 14px; bottom: 14px; }
  .floating-action { width: 50px; min-height: 50px; }
  .note-data { grid-template-columns: 1fr auto; }
}
