:root {
  --bg: #f4f1ea;
  --surface: #fbf9f4;
  --surface-2: #ffffff;
  --ink: #20211d;
  --ink-soft: #4a4d44;
  --muted: #8a8d80;
  --line: #e2ddd0;
  --teal: #1f4e46;
  --teal-soft: #2d6a5f;
  --amber: #c9742f;
  --amber-soft: #e8a05a;
  --rose: #a8453c;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(32,33,29,.04), 0 8px 28px rgba(32,33,29,.07);
  --shadow-lg: 0 12px 50px rgba(32,33,29,.14);
  --sidebar-w: 320px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --dur: 280ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--teal);
  color: #e8e6dc;
  display: flex;
  flex-direction: column;
  padding: 28px 0 16px;
  overflow-y: auto;
  z-index: 40;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}
.sidebar::-webkit-scrollbar { width: 7px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 4px; }

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 26px 24px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 14px;
}
.brand-mark {
  flex: none;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: var(--amber);
  color: #fff;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: .5px;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(201,116,47,.4);
  transition: transform var(--dur) var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-6deg) scale(1.05); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.brand-text small { color: rgba(232,230,220,.6); font-size: 12.5px; }

.nav { flex: 1; padding: 4px 14px; }
.nav-squad { margin-bottom: 4px; }
.nav-squad-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  background: none;
  border: none;
  color: #dcd9cd;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-squad-btn:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-squad-btn .ico { font-size: 17px; flex: none; }
.nav-squad-btn .n {
  flex: none;
  width: 21px; height: 21px;
  display: grid; place-items: center;
  font-size: 11px;
  background: rgba(255,255,255,.12);
  border-radius: 6px;
  color: rgba(255,255,255,.75);
}
.nav-squad-btn .label { flex: 1; }
.nav-squad-btn .chev {
  flex: none;
  transition: transform var(--dur) var(--ease);
  opacity: .5;
  font-size: 12px;
}
.nav-squad.open .chev { transform: rotate(90deg); }

.nav-docs {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding: 3px 0 8px 44px;
}
.nav-squad.open .nav-docs { display: flex; }
.nav-doc {
  display: block;
  padding: 7px 12px;
  color: rgba(220,217,205,.72);
  text-decoration: none;
  font-size: 13px;
  border-radius: 7px;
  border-left: 2px solid transparent;
  transition: all var(--dur) var(--ease);
}
.nav-doc:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-doc.active {
  color: #fff;
  background: rgba(201,116,47,.22);
  border-left-color: var(--amber-soft);
  font-weight: 500;
}

.sidebar-foot {
  padding: 16px 26px 4px;
  border-top: 1px solid rgba(255,255,255,.1);
  margin-top: 10px;
}
.sidebar-foot p { font-size: 12px; color: rgba(232,230,220,.55); }
.sidebar-foot .muted { color: rgba(232,230,220,.35); }

/* ---------- Main ---------- */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.content { flex: 1; padding: 0; }

/* ---------- Home ---------- */
.hero {
  padding: clamp(48px, 7vw, 110px) clamp(24px, 6vw, 96px) clamp(40px, 5vw, 72px);
  background:
    radial-gradient(120% 130% at 100% 0%, rgba(201,116,47,.12) 0%, transparent 55%),
    radial-gradient(90% 90% at 0% 100%, rgba(31,78,70,.09) 0%, transparent 60%),
    var(--surface);
  border-bottom: 1px solid var(--line);
}
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 22px;
}
.hero-kicker::before { content: ""; width: 26px; height: 2px; background: var(--amber); display: inline-block; }
.hero h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.4rem, 1rem + 5vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -.02em;
  max-width: 16ch;
  margin-bottom: 22px;
}
.hero h1 em { font-style: italic; color: var(--teal); }
.hero-lead {
  font-size: clamp(1.05rem, .95rem + .5vw, 1.3rem);
  color: var(--ink-soft);
  max-width: 60ch;
  margin-bottom: 30px;
}
.hero-meta { display: flex; flex-wrap: wrap; gap: 28px; }
.hero-meta div { display: flex; flex-direction: column; }
.hero-meta dt { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 3px; }
.hero-meta dd { font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--ink); }

.home-body { padding: clamp(40px, 5vw, 72px) clamp(24px, 6vw, 96px); }
.section-label {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: -.01em;
}
.section-sub { color: var(--muted); margin-bottom: 34px; max-width: 56ch; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 24px 22px;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--amber), var(--amber-soft));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur) var(--ease);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: #d4cdba; }
.card:hover::before { transform: scaleX(1); }
.card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-ico { font-size: 30px; }
.card-n {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 20px;
}
.card h3 { font-family: var(--serif); font-size: 1.45rem; font-weight: 600; margin-bottom: 9px; letter-spacing: -.01em; }
.card p { color: var(--ink-soft); font-size: 14.5px; flex: 1; }
.card-go {
  margin-top: 18px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--teal-soft);
}
.card-go .arr { transition: transform var(--dur) var(--ease); }
.card:hover .card-go .arr { transform: translateX(4px); }

/* ---------- Doc view ---------- */
.doc-head {
  padding: clamp(36px, 5vw, 64px) clamp(24px, 6vw, 96px) 0;
  max-width: 920px;
}
.crumbs { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); margin-bottom: 18px; flex-wrap: wrap; }
.crumbs a { color: var(--teal-soft); text-decoration: none; font-weight: 500; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { opacity: .5; }
.doc-squad-tag {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--amber);
  margin-bottom: 14px;
}
.doc-title { font-family: var(--serif); font-size: clamp(1.9rem, 1rem + 3vw, 3rem); font-weight: 600; line-height: 1.08; letter-spacing: -.02em; margin-bottom: 12px; }
.doc-desc { color: var(--ink-soft); font-size: 1.1rem; max-width: 64ch; }
.doc-divider { height: 1px; background: var(--line); margin: 36px clamp(24px, 6vw, 96px) 0; }

.prose {
  padding: 36px clamp(24px, 6vw, 96px) 60px;
  max-width: 920px;
  font-size: 16.5px;
  color: var(--ink-soft);
}
.prose > *:first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--serif);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.01em;
}
.prose h1 { font-size: 1.9rem; margin: 2.2em 0 .6em; }
.prose h2 {
  font-size: 1.5rem;
  margin: 1.9em 0 .6em;
  padding-bottom: .3em;
  border-bottom: 2px solid var(--line);
}
.prose h3 { font-size: 1.22rem; margin: 1.6em 0 .5em; color: var(--teal); }
.prose h4 { font-size: 1.05rem; margin: 1.4em 0 .4em; }
.prose p { margin: 0 0 1.1em; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose em { font-style: italic; }
.prose a { color: var(--teal-soft); text-decoration: underline; text-underline-offset: 2px; }
.prose ul, .prose ol { margin: 0 0 1.2em 1.4em; }
.prose li { margin-bottom: .4em; }
.prose blockquote {
  margin: 1.4em 0;
  padding: 4px 0 4px 22px;
  border-left: 3px solid var(--amber);
  background: linear-gradient(90deg, rgba(201,116,47,.06), transparent);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.12rem;
  font-style: italic;
}
.prose blockquote p { margin-bottom: .4em; }
.prose code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .88em;
  background: #efece2;
  padding: .15em .42em;
  border-radius: 5px;
  color: var(--rose);
}
.prose pre {
  background: #232520;
  color: #e8e6dc;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 1.3em 0;
  font-size: 13.5px;
  line-height: 1.55;
}
.prose pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
.prose hr { border: none; border-top: 1px solid var(--line); margin: 2.2em 0; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 14.5px;
  display: block;
  overflow-x: auto;
}
.prose thead { background: var(--teal); color: #fff; }
.prose th { text-align: left; padding: 11px 14px; font-weight: 600; white-space: nowrap; }
.prose td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose tbody tr:nth-child(even) { background: rgba(31,78,70,.03); }
.prose tbody tr:hover { background: rgba(201,116,47,.06); }

/* doc nav (prev/next) */
.doc-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(24px, 6vw, 96px) 40px;
  max-width: 920px;
  flex-wrap: wrap;
}
.doc-nav a {
  flex: 1 1 240px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.doc-nav a:hover { border-color: var(--amber-soft); transform: translateY(-2px); }
.doc-nav a.next { text-align: right; align-items: flex-end; }
.doc-nav small { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.doc-nav span { font-family: var(--serif); font-weight: 600; color: var(--ink); }

.loading { padding: 80px clamp(24px, 6vw, 96px); color: var(--muted); font-size: 15px; }

/* ---------- Footer ---------- */
.site-foot {
  padding: 30px clamp(24px, 6vw, 96px);
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.site-foot p { font-size: 13px; color: var(--ink-soft); }
.site-foot .muted { color: var(--muted); margin-top: 3px; }
.muted { color: var(--muted); }

/* ---------- Mobile ---------- */
.menu-toggle {
  display: none;
  position: fixed;
  top: 16px; left: 16px;
  z-index: 60;
  width: 46px; height: 46px;
  background: var(--teal);
  border: none;
  border-radius: 11px;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  box-shadow: var(--shadow);
}
.menu-toggle span { width: 20px; height: 2px; background: #fff; border-radius: 2px; transition: all var(--dur) var(--ease); }
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(32,33,29,.5);
  z-index: 35;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--dur) var(--ease); width: min(86vw, 340px); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .overlay.show { display: block; opacity: 1; }
  body.nav-open { overflow: hidden; }
  .hero { padding-top: 84px; }
  .doc-head { padding-top: 84px; }
}

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