:root {
  color-scheme: light;
  --ink: #4f3528;
  --muted: #806b5d;
  --paper: #fffaf0;
  --orange: #c86d2c;
  --line: rgba(126, 85, 53, 0.18);
  --shadow: 0 18px 52px rgba(104, 66, 35, 0.17);
  --serif: "STKaiti", "KaiTi", "Kaiti SC", "Noto Serif CJK SC", "Noto Serif SC", "Songti SC", "SimSun", serif;
  --sans: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background-color: #f3dfb9;
  background-image: linear-gradient(rgba(255, 250, 239, 0.22), rgba(247, 226, 189, 0.28)), url("../assets/cozy-room-background.jpg");
  background-position: center center;
  background-size: cover;
  background-attachment: fixed;
  background-repeat: no-repeat;
  font-family: var(--sans);
}

a { color: inherit; }
button, input { font: inherit; }

.sr-only,
.skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 15px;
  border-radius: 10px;
  color: white;
  background: var(--ink);
}

.notes-site-header {
  position: sticky;
  top: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(92vw, 1180px);
  min-height: 72px;
  margin: 14px auto 0;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 250, 239, 0.92);
  box-shadow: 0 12px 34px rgba(105, 66, 37, 0.14);
  backdrop-filter: blur(14px);
}

.notes-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  text-decoration: none;
}

.notes-brand > span {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  color: #9d5d2f;
  background: #f4d69d;
  box-shadow: inset 0 0 0 4px rgba(255, 250, 235, 0.75);
}

.notes-site-header nav { display: flex; gap: 8px; }

.notes-site-header nav a {
  padding: 10px 13px;
  border-radius: 999px;
  color: #785f50;
  font-size: 13px;
  text-decoration: none;
}

.notes-site-header nav a:hover,
.notes-site-header nav a.active { color: #9d5128; background: #f6e4c6; }

.notes-main,
.article-main {
  width: min(92vw, 980px);
  margin: 42px auto 0;
}

.notes-intro {
  padding: 37px clamp(25px, 6vw, 70px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 250, 239, 0.9);
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 7px;
  color: #ad6b43;
  font: 700 10px Georgia, serif;
  letter-spacing: 0.22em;
}

.notes-intro h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(34px, 6vw, 55px);
  font-weight: 700;
}

.notes-intro > p:last-child { margin: 11px 0 0; color: var(--muted); line-height: 1.7; }

.notes-controls {
  display: grid;
  gap: 14px;
  margin: 20px 0 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 249, 235, 0.88);
  box-shadow: 0 10px 25px rgba(99, 61, 34, 0.12);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 15px;
  border: 1px solid rgba(137, 92, 57, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
}

.search-box > span:first-child { color: #aa6b42; font-size: 21px; }

.search-box input {
  width: 100%;
  height: 43px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

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

.tag-filters button {
  padding: 7px 13px;
  border: 1px solid rgba(135, 89, 55, 0.16);
  border-radius: 999px;
  color: #745e50;
  background: #fff8e9;
  cursor: pointer;
}

.tag-filters button:hover,
.tag-filters button.active { color: white; border-color: var(--orange); background: var(--orange); }

.notes-count { margin: 20px 4px 8px; color: #8b7464; font-size: 12px; }
.notes-years { display: grid; gap: 30px; }

.notes-year {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 250, 239, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(9px);
}

.year-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 15px;
  color: #a65f34;
  font: 700 22px Georgia, serif;
}

.year-heading::after { height: 1px; flex: 1; background: linear-gradient(90deg, #d9b68e, transparent); content: ""; }
.notes-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }

.note-card {
  min-width: 0;
  border: 1px solid rgba(135, 90, 56, 0.16);
  border-radius: 16px;
  background: linear-gradient(145deg, #fffdf5, #f8ecd5);
  box-shadow: 0 8px 20px rgba(96, 60, 33, 0.11);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.note-card:hover { transform: translateY(-3px) rotate(-0.2deg); box-shadow: 0 14px 26px rgba(96, 60, 33, 0.16); }
.note-card-link { display: flex; min-height: 230px; padding: 22px; flex-direction: column; text-decoration: none; }
.note-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #a36a45; font-size: 11px; }
.note-mood { padding: 4px 8px; border-radius: 999px; background: #f1dfbe; }
.note-card h3 { margin: 20px 0 8px; font-size: clamp(22px, 3vw, 29px); line-height: 1.35; }
.note-summary { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
.note-card-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 20px; }
.note-tags { display: flex; flex-wrap: wrap; gap: 5px; color: #8b745f; font-size: 11px; }
.read-note { flex: 0 0 auto; color: #a6532b; font-size: 11px; }

.loading-note,
.empty-note {
  margin: 0;
  padding: 34px;
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 250, 239, 0.88);
  text-align: center;
}

.notes-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: min(92vw, 980px);
  margin: 48px auto 0;
  padding: 25px 10px 35px;
  color: #735e50;
  font-size: 12px;
}

.notes-footer a { color: #9d522b; text-decoration: none; }

.article-main { width: min(92vw, 820px); }

.article-paper {
  position: relative;
  padding: clamp(30px, 7vw, 72px);
  border: 1px solid var(--line);
  border-radius: 12px 18px 14px 17px;
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(135, 103, 73, 0.065) 31px 32px),
    rgba(255, 252, 243, 0.96);
  box-shadow: var(--shadow);
}

.article-paper::before,
.article-paper::after {
  position: absolute;
  top: -10px;
  width: 75px;
  height: 25px;
  background: rgba(224, 180, 130, 0.55);
  content: "";
}

.article-paper::before { left: 7%; transform: rotate(-4deg); }
.article-paper::after { right: 7%; transform: rotate(5deg); }
.back-to-notes { color: #a15b34; font-size: 12px; text-decoration: none; }
.article-header { margin-top: 30px; padding-bottom: 28px; border-bottom: 1px dashed #d5b690; }
.article-mood { margin: 0 0 10px; color: #ad6840; font-size: 12px; letter-spacing: 0.12em; }
.article-header h1 { margin: 0; font-family: var(--serif); font-size: clamp(34px, 7vw, 55px); line-height: 1.25; }
.article-summary { margin: 15px 0 0; color: var(--muted); font-size: 15px; line-height: 1.75; }
.article-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 20px; color: #8a7567; font-size: 11px; }
.article-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.article-tags a { padding: 5px 9px; border-radius: 999px; color: #8b603f; background: #f2e2c5; font-size: 11px; text-decoration: none; }

.article-content { margin-top: 36px; font-size: 16px; line-height: 2; }
.article-content h1 { margin: 2.2em 0 0.75em; font-family: var(--serif); font-size: 32px; line-height: 1.35; }
.article-content h2 { margin: 2.1em 0 0.7em; font-family: var(--serif); font-size: 28px; line-height: 1.4; }
.article-content h3 { margin: 1.8em 0 0.6em; font-size: 22px; }
.article-content h4 { margin: 1.6em 0 0.5em; font-size: 18px; }
.article-content h5 { margin: 1.45em 0 0.45em; color: #6f5545; font-size: 16px; }
.article-content h6 { margin: 1.35em 0 0.4em; color: #846f61; font-size: 14px; letter-spacing: 0.02em; }
.article-content p { margin: 1.15em 0; }
.article-content a { color: #a4512a; text-decoration-color: #d69a72; text-underline-offset: 3px; }
.article-content img { display: block; max-width: 100%; height: auto; margin: 25px auto; border-radius: 12px; box-shadow: 0 10px 25px rgba(90, 53, 27, 0.15); }
.article-content blockquote { margin: 25px 0; padding: 13px 20px; border-left: 4px solid #d48a57; color: #745f51; background: rgba(246, 228, 198, 0.58); }
.article-content blockquote p { margin: 0; }
.article-content pre { overflow-x: auto; margin: 24px 0; padding: 18px; border-radius: 12px; color: #f7ead8; background: #4d3b31; font: 13px/1.7 Consolas, monospace; }
.article-content code:not(pre code) { padding: 2px 6px; border-radius: 5px; color: #934925; background: #f1dfc2; font: 0.9em Consolas, monospace; }
.article-content li { margin: 0.45em 0; }
.article-content .task-list { padding-left: 0; list-style: none; }
.article-content .task-list-item { display: flex; align-items: flex-start; gap: 8px; }
.article-content .task-list-item input { width: 16px; height: 16px; margin-top: 7px; accent-color: #a86138; }
.article-content .table-wrap { max-width: 100%; margin: 25px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.article-content table { width: 100%; border-collapse: collapse; background: rgba(255, 252, 244, 0.68); font-size: 14px; line-height: 1.65; }
.article-content th, .article-content td { min-width: 90px; padding: 10px 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; }
.article-content th { color: #684432; background: #f2dfc2; font-weight: 800; }
.article-content tr:last-child td { border-bottom: 0; }
.article-content th:last-child, .article-content td:last-child { border-right: 0; }
.article-content hr { width: 38%; margin: 40px auto; border: 0; border-top: 1px dashed #d0ac84; }

.article-ending { margin-top: 45px; padding-top: 24px; border-top: 1px dashed #d5b690; color: #987661; text-align: center; }
.article-ending span { color: #839157; font-size: 24px; }
.article-ending p { margin: 6px 0 0; }

.article-navigation { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.article-navigation a { display: grid; gap: 5px; padding: 17px 20px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 250, 239, 0.92); box-shadow: 0 8px 20px rgba(96, 60, 33, 0.11); text-decoration: none; }
.article-navigation span { color: #a66a44; font-size: 10px; }
.article-navigation strong { font-size: 14px; }

:focus-visible { outline: 3px solid rgba(198, 105, 44, 0.55); outline-offset: 4px; }

@media (max-width: 680px) {
  body { background-position: center top; background-attachment: scroll; }
  .notes-site-header { top: 8px; width: calc(100vw - 18px); margin-top: 8px; padding: 8px 11px; }
  .notes-brand strong { font-size: 15px; }
  .notes-brand > span { width: 34px; height: 34px; }
  .notes-site-header nav a { padding: 8px; font-size: 11px; }
  .notes-site-header nav a:first-child { display: none; }
  .notes-main, .article-main { width: calc(100vw - 18px); margin-top: 25px; }
  .notes-intro { padding: 28px 18px; }
  .notes-controls, .notes-year { padding: 14px; }
  .notes-grid { grid-template-columns: 1fr; }
  .note-card-link { min-height: 205px; padding: 19px; }
  .article-paper { padding: 34px 20px; }
  .article-content { font-size: 15px; line-height: 1.9; }
  .article-navigation { grid-template-columns: 1fr; }
  .notes-footer { flex-direction: column; gap: 7px; margin-top: 30px; }
}

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