:root {
  --bg: #f9f6f1;
  --paper: #fdfcfa;
  --ink: #1a1814;
  --ink-light: #4a4540;
  --ink-soft: #595146;
  --ink-muted: #8a8278;
  --stone: #c9bfb0;
  --line: #ede8df;
  --sand: #ede8df;
  --accent: #c17f4a;
  --accent-soft: #e8c99e;
  --brand: #2f4a3a;
  --warm-white: #fdfcfa;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 16px 34px rgba(24, 18, 12, 0.08);
  --content-max: 1180px;
  --pad: 32px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  background: var(--warm-white);
  color: var(--ink-soft);
  font-family: "DM Sans", sans-serif;
  font-weight: 300;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.post-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 60px;
  border-bottom: 1px solid var(--sand);
  background: rgba(253, 252, 250, 0.92);
  backdrop-filter: blur(12px);
}

.post-nav-logo {
  font-family: "Cormorant Garamond", serif;
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.post-nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 40px;
}

.post-nav-links a {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-light);
  transition: color 0.2s;
}

.post-nav-links a:hover {
  color: var(--ink);
}

.post-nav-links .post-nav-cta {
  padding: 9px 22px;
  background: var(--ink);
  color: var(--warm-white);
}

.post-nav-links .post-nav-cta:hover {
  background: var(--accent);
  color: #fff;
}

.post-nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}

.post-nav-toggle span {
  width: 18px;
  height: 1.5px;
  background: var(--ink);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.post-nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}

.post-nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.post-nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

.system-main {
  width: min(var(--content-max), calc(100vw - 2 * var(--pad)));
  margin: 0 auto;
  padding: 124px 0 90px;
  animation: page-in 0.7s ease both;
}

.system-hero {
  max-width: 740px;
  margin-bottom: 38px;
}

.system-kicker {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.system-title {
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(46px, 5.5vw, 70px);
  font-weight: 400;
  line-height: 0.97;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.system-lead {
  margin-top: 18px;
  font-size: clamp(16px, 2vw, 19px);
  color: var(--ink-soft);
  max-width: 68ch;
}

.system-meta {
  margin-top: 20px;
  display: inline-flex;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(252, 249, 243, 0.84);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.system-meta strong {
  color: var(--ink);
  font-weight: 500;
}

.system-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}

.system-toc {
  position: sticky;
  top: 98px;
  border: 1px solid var(--line);
  background: rgba(252, 250, 246, 0.88);
  border-radius: var(--radius-sm);
  padding: 22px 20px;
  box-shadow: 0 8px 16px rgba(22, 16, 10, 0.03);
}

.system-toc h2 {
  font-family: "Cormorant Garamond", serif;
  font-size: 25px;
  color: var(--ink);
  font-weight: 400;
  margin-bottom: 12px;
}

.system-toc ul {
  list-style: none;
}

.system-toc li + li {
  margin-top: 10px;
}

.system-toc a {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
}

.system-toc a:hover {
  color: var(--ink);
}

.system-toc-extra {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.system-toc-extra a {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.system-article {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: none;
  padding: clamp(30px, 4vw, 52px);
}

.system-article section + section {
  margin-top: 34px;
}

.system-article h2 {
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(31px, 3.3vw, 40px);
  line-height: 1.08;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 14px;
}

.system-article p {
  margin-bottom: 14px;
  max-width: 74ch;
}

.system-article ul {
  margin: 14px 0 10px;
  padding-left: 24px;
}

.system-article li {
  margin-bottom: 10px;
}

.system-article strong {
  color: var(--ink);
  font-weight: 500;
}

.system-callout {
  margin-top: 14px;
  border-left: 3px solid var(--accent);
  background: rgba(231, 200, 168, 0.22);
  padding: 16px 18px;
  border-radius: 0 10px 10px 0;
  color: #413628;
}

.system-contact {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 18px;
}

.system-contact p {
  margin-bottom: 4px;
}

.system-contact a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.error-main {
  display: flex;
  align-items: center;
  min-height: calc(100vh - 148px);
}

.error-panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  background: var(--paper);
  box-shadow: none;
  padding: clamp(38px, 7vw, 88px);
}

.error-code {
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(82px, 18vw, 176px);
  line-height: 0.8;
  color: var(--brand);
  letter-spacing: -0.04em;
}

.error-title {
  margin-top: 10px;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(42px, 7vw, 76px);
  line-height: 0.95;
  font-weight: 400;
  color: var(--ink);
}

.error-lead {
  margin-top: 16px;
  max-width: 62ch;
  font-size: clamp(16px, 2vw, 20px);
  color: #4f463b;
}

.error-actions {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-solid,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 20px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn-solid {
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
}

.btn-solid:hover {
  background: #2c251e;
  color: #fff;
  transform: translateY(-1px);
}

.btn-ghost {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.6);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.94);
  transform: translateY(-1px);
}

.error-note {
  margin-top: 18px;
  font-size: 14px;
  color: var(--ink-muted);
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1060px) {
  .system-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .system-toc {
    position: static;
    top: auto;
  }

  .system-toc ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 8px 12px;
  }
}

@media (max-width: 1024px) {
  .post-nav {
    padding: 18px 24px;
  }

  .post-nav-links {
    gap: 24px;
  }
}

@media (max-width: 900px) {
  :root {
    --pad: 22px;
  }

  .system-toc {
    display: none;
  }

  .post-nav-links {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 24px;
    min-width: 220px;
    padding: 14px 16px;
    flex-direction: column;
    gap: 12px;
    border-radius: 14px;
    background: rgba(253, 252, 250, 0.95);
    border: 1px solid var(--sand);
    backdrop-filter: blur(12px);
  }

  .post-nav-links.open { display: flex; }

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

  .post-nav-links .post-nav-cta {
    padding: 0;
    background: transparent;
    color: inherit;
  }

  .post-nav-links .post-nav-cta:hover {
    background: transparent;
    color: var(--ink);
  }

  .system-article {
    border-radius: 16px;
    padding: 24px 20px;
  }

  .system-main { padding: 108px 0 70px; }

  .error-main {
    min-height: calc(100vh - 166px);
  }
}
