:root {
  --paper: #f5f1ea;
  --paper-strong: #e9e0d0;
  --ink: #1f2d2d;
  --muted: #536664;
  --moss: #5e7a68;
  --sage: #8aa38d;
  --gold: #d6c07d;
  --clay: #c88e63;
  --line: rgba(31, 45, 45, 0.12);
  --panel: rgba(255, 255, 255, 0.2);
  --shadow: rgba(20, 29, 25, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", sans-serif;
  background:
    radial-gradient(
      circle at 12% 14%,
      rgba(147, 177, 151, 0.18),
      transparent 20%
    ),
    radial-gradient(
      circle at 82% 18%,
      rgba(200, 216, 191, 0.18),
      transparent 18%
    ),
    radial-gradient(
      circle at 70% 78%,
      rgba(152, 177, 167, 0.16),
      transparent 22%
    ),
    linear-gradient(180deg, #f9f6f2 0%, #f5f1ea 48%, #f2efe8 100%);
  background-attachment: fixed;
  color: var(--ink);
  position: relative;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 34rem;
  height: 34rem;
  border-radius: 58% 42% 60% 40% / 42% 60% 40% 58%;
  background:
    radial-gradient(
      circle at 50% 32%,
      rgba(255, 255, 255, 0.72),
      rgba(255, 255, 255, 0) 26%
    ),
    radial-gradient(
      circle at 40% 52%,
      rgba(158, 190, 164, 0.56),
      rgba(158, 190, 164, 0.14) 36%,
      transparent 62%
    ),
    radial-gradient(
      circle at 62% 56%,
      rgba(124, 164, 136, 0.42),
      rgba(124, 164, 136, 0.12) 30%,
      transparent 54%
    ),
    radial-gradient(
      circle at 52% 50%,
      rgba(193, 214, 171, 0.26),
      transparent 42%
    );
  filter: blur(1.5px);
  z-index: 0;
  pointer-events: none;
}

body::before {
  left: -8rem;
  top: -2rem;
}

body::after {
  right: -7rem;
  bottom: -4rem;
  border-radius: 56% 44% 58% 42% / 58% 36% 64% 42%;
  background:
    radial-gradient(
      circle at 46% 32%,
      rgba(255, 255, 255, 0.7),
      rgba(255, 255, 255, 0) 26%
    ),
    radial-gradient(
      circle at 44% 48%,
      rgba(145, 173, 155, 0.46),
      rgba(145, 173, 155, 0.12) 34%,
      transparent 60%
    ),
    radial-gradient(
      circle at 60% 56%,
      rgba(120, 157, 130, 0.38),
      rgba(120, 157, 130, 0.12) 32%,
      transparent 52%
    );
}

img {
  max-width: 100%;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1360px, calc(100% - 32px));
  margin: 18px auto 40px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 50px var(--shadow);
  overflow: clip;
}

.page-shell::before,
.page-shell::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  background:
    radial-gradient(
      circle at 50% 42%,
      rgba(255, 255, 255, 0.72),
      rgba(255, 255, 255, 0) 28%
    ),
    radial-gradient(
      circle at 42% 52%,
      rgba(160, 188, 138, 0.3),
      rgba(160, 188, 138, 0.1) 30%,
      transparent 58%
    ),
    radial-gradient(
      circle at 58% 54%,
      rgba(113, 158, 129, 0.28),
      rgba(113, 158, 129, 0.08) 24%,
      transparent 52%
    );
  border-radius: 58% 42% 60% 40% / 42% 60% 40% 58%;
  filter: blur(1px);
  pointer-events: none;
}

.page-shell::before {
  top: -120px;
  right: 12%;
  transform: rotate(18deg);
}

.page-shell::after {
  bottom: -120px;
  left: 10%;
  transform: rotate(-18deg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 18px 28px 14px;
  border-bottom: 1px solid rgba(31, 45, 45, 0.08);
  background: rgba(250, 247, 242, 0.96);
  backdrop-filter: blur(8px);
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 1.6px;
  background: var(--ink);
  border-radius: 999px;
}

.brand {
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  position: relative;
  padding-bottom: 4px;
}

.site-nav-item {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.site-nav-link,
.site-nav-link--main,
.site-nav-link--toggle {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.site-nav-link--main,
.site-nav-link--toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  padding: 0.2rem 0.1rem 0.4rem;
}

.site-nav-link--toggle {
  display: none;
}

.site-nav-submenu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  display: grid;
  gap: 0.25rem;
  min-width: 220px;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(250, 247, 242, 0.96);
  box-shadow: 0 14px 30px rgba(25, 34, 28, 0.08);
}

.site-nav-submenu[hidden] {
  display: none;
}

.site-nav-submenu-group {
  display: grid;
  gap: 0.15rem;
}

.site-nav-submenu-group-title {
  padding: 0.2rem 0.45rem 0.12rem;
  color: var(--muted);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.site-nav-submenu a {
  display: block;
  padding: 0.62rem 0.7rem;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.74rem;
  line-height: 1.4;
}

.site-nav-submenu a:hover,
.site-nav-submenu a:focus-visible {
  background: rgba(123, 156, 131, 0.08);
  border-color: rgba(31, 45, 45, 0.08);
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--clay);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}

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

.notes-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  min-height: 760px;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  padding: 24px 18px 20px;
}

.sidebar-header {
  margin-bottom: 20px;
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1rem;
  transition: transform 0.2s ease;
}

.sidebar.open .sidebar-toggle {
  transform: rotate(180deg);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--moss);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.sidebar h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(2rem, 2.8vw, 3rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
  font-weight: 600;
}

.notes-tree {
  display: grid;
  gap: 8px;
}

.tree-group {
  margin-top: 10px;
}

.tree-group-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.note-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.72rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.note-link:hover,
.note-link.active {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--line);
}

.reader {
  padding: 28px;
}

.reader-content {
  position: relative;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--line);
  border-radius: 24px;
  min-height: 620px;
  padding: 30px 30px 48px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.reader-content::before,
.reader-content::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  background: radial-gradient(
    circle at center,
    rgba(121, 159, 137, 0.18),
    rgba(121, 159, 137, 0.02) 60%,
    transparent 72%
  );
  border-radius: 50%;
  pointer-events: none;
}

.reader-content::before {
  right: -30px;
  top: 20px;
}

.reader-content::after {
  left: -25px;
  bottom: 28px;
}

.loading {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.markdown-body {
  position: relative;
  z-index: 1;
  font-size: 1.02rem;
  line-height: 1.8;
  color: var(--ink);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  font-family: "Fraunces", Georgia, serif;
  letter-spacing: -0.05em;
  line-height: 1.05;
  margin-top: 1.8em;
  margin-bottom: 0.8em;
  color: var(--ink);
}

.markdown-body h1 {
  font-size: clamp(2.4rem, 4vw, 4rem);
}

.markdown-body h2 {
  font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.markdown-body p,
.markdown-body li {
  color: var(--ink);
}

.markdown-body a {
  color: var(--moss);
}

.markdown-body blockquote {
  margin: 1.4rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--clay);
  color: var(--muted);
  font-style: italic;
}

.markdown-body code {
  background: rgba(31, 45, 45, 0.05);
  padding: 0.12rem 0.28rem;
  border-radius: 6px;
  font-size: 0.92em;
}

.markdown-body pre {
  background: rgba(31, 45, 45, 0.04);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  overflow-x: auto;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.4rem;
}

@media (max-width: 980px) {
  .notes-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .reader {
    padding: 18px;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 12px, 1000px);
    margin: 10px auto 24px;
    border-radius: 22px;
  }

  .topbar {
    position: relative;
    gap: 0.8rem;
    padding: 14px 16px 12px;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .site-nav {
    position: absolute;
    top: calc(100% + 8px);
    left: 12px;
    right: 12px;
    z-index: 30;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    padding: 0.6rem 0.6rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    background: rgba(22, 31, 29, 0.96);
    backdrop-filter: blur(12px);
    box-shadow: 0 16px 32px rgba(25, 34, 28, 0.2);
  }

  .site-nav.open {
    display: flex;
  }

  .site-nav a,
  .site-nav-link {
    width: 100%;
    font-size: 0.76rem;
    padding: 0.8rem 0.7rem;
    border-radius: 10px;
    color: rgba(245, 241, 234, 0.96);
    font-weight: 600;
    background: transparent;
    border: 1px solid transparent;
  }

  .site-nav a:hover,
  .site-nav a:focus-visible,
  .site-nav-link:hover,
  .site-nav-link:focus-visible {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.08);
  }

  .site-nav-item {
    display: block;
    width: 100%;
  }

  .site-nav-link--main {
    display: none;
  }

  .site-nav-link--toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    text-align: left;
    cursor: pointer;
    width: 100%;
    color: rgba(245, 241, 234, 0.96);
  }

  .site-nav-caret {
    font-size: 0.9rem;
    opacity: 0.8;
  }

  .site-nav-item--notes.open .site-nav-caret {
    transform: rotate(180deg);
  }

  .site-nav-submenu {
    display: grid;
    gap: 0.25rem;
    margin-top: 0.2rem;
    padding: 0.2rem 0.15rem 0.1rem;
    position: static;
    min-width: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .site-nav-submenu-group {
    display: grid;
    gap: 0.12rem;
    padding: 0.1rem 0 0.1rem;
  }

  .site-nav-submenu-group-title {
    color: rgba(245, 241, 234, 0.72);
    padding: 0.1rem 0.5rem 0;
    font-size: 0.56rem;
    letter-spacing: 0.12em;
  }

  .site-nav-submenu a {
    width: 100%;
    display: block;
    font-size: 0.7rem;
    line-height: 1.4;
    padding: 0.72rem 0.7rem;
    border-radius: 8px;
    color: rgba(245, 241, 234, 0.94);
    text-decoration: none;
    border: 1px solid transparent;
  }

  body.menu-open .page-shell {
    overflow: visible;
  }

  body.menu-open main,
  body.menu-open .footer {
    opacity: 0.22;
    filter: blur(0.5px);
    transition:
      opacity 0.18s ease,
      filter 0.18s ease;
    pointer-events: none;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 18px 14px 12px;
  }

  .sidebar .sidebar-header {
    margin-bottom: 0;
  }

  .notes-tree {
    display: none;
    flex-direction: column;
    gap: 6px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition:
      max-height 0.25s ease,
      opacity 0.2s ease;
  }

  .sidebar.open .notes-tree {
    display: flex;
    max-height: 2200px;
    opacity: 1;
    margin-top: 14px;
  }

  .tree-group {
    margin-top: 0;
  }

  .tree-group-title {
    margin: 0 0 6px;
  }

  .note-link {
    min-height: 44px;
    padding: 0.7rem 0.7rem;
    border-radius: 10px;
  }

  .reader {
    padding: 14px;
  }

  .reader-content {
    border-radius: 18px;
    padding: 18px 16px 24px;
    min-height: 480px;
  }

  .markdown-body {
    font-size: 0.98rem;
    line-height: 1.7;
  }

  .markdown-body h1 {
    font-size: 2.2rem;
  }

  .markdown-body h2 {
    font-size: 1.7rem;
  }
}
