@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&family=Lora:ital,wght@0,400;0,500;0,600;1,400&display=swap');

:root {
  --bg-primary: #EEF2EE;
  --bg-card: #F5F0E8;
  --bg-editor: #FFFFFF;
  --bg-sidebar: #F7F7F5;
  --bg-overlay: rgba(74, 85, 71, 0.06);
  --bg-dark: #2A3329;

  --text-primary: #2A3329;
  --text-secondary: #4F594D;
  --text-tertiary: #6F7A6C;
  --text-inverse: #F5F0E8;
  --text-link: #4A7C59;

  --accent-sage: #4A7C59;
  --accent-terracotta: #C8553D;
  --accent-sand: #D4A373;
  --accent-sky: #5B8FA8;
  --accent-rose: #C97B7B;
  --accent-lavender: #8B7FA8;
  --accent-gold: #C9A84C;

  --sage-50: #EEF2EE;
  --sage-100: #D4E8D9;
  --terracotta-50: #F5D4CC;
  --sand-50: #F5E6D3;
  --sky-50: #D4E4ED;
  --rose-50: #F5D4D4;
  --lavender-50: #E4DFF0;
  --gold-50: #F5EDD4;

  --success: #4A7C59;
  --warning: #C9A84C;
  --error: #C8553D;
  --info: #5B8FA8;

  --shadow-sm: 0 1px 3px rgba(42,51,41,0.06);
  --shadow-md: 0 4px 12px rgba(42,51,41,0.08);
  --shadow-lg: 0 8px 24px rgba(42,51,41,0.12);
  --shadow-focus: 0 0 0 3px rgba(74,124,89,0.15);

  --border-subtle: 1px solid rgba(42,51,41,0.08);
  --border-default: 1px solid rgba(42,51,41,0.12);
  --border-active: 1px solid #4A7C59;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-serif: 'Lora', Georgia, 'Times New Roman', serif;

  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; border-color: rgba(42,51,41,0.08); }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Typography ---------- */

.display-lg { font-family: var(--font-display); font-size: 36px; line-height: 1.15; letter-spacing: -0.015em; font-weight: 700; }
.display-md { font-family: var(--font-display); font-size: 28px; line-height: 1.2; letter-spacing: -0.01em; font-weight: 700; }
.heading-lg { font-size: 22px; line-height: 1.3; letter-spacing: -0.005em; font-weight: 600; }
.heading-md { font-size: 18px; line-height: 1.35; font-weight: 600; }
.heading-sm { font-size: 15px; line-height: 1.4; letter-spacing: 0.005em; font-weight: 600; }
.body-lg { font-size: 16px; line-height: 1.7; }
.body-md { font-size: 15px; line-height: 1.6; }
.body-sm { font-size: 13px; line-height: 1.5; letter-spacing: 0.01em; font-weight: 500; }
.mono-md { font-family: var(--font-mono); font-size: 14px; line-height: 1.6; }
.mono-sm { font-family: var(--font-mono); font-size: 12px; line-height: 1.5; letter-spacing: 0.01em; font-weight: 500; }
.serif { font-family: var(--font-serif); font-size: 16px; line-height: 1.65; letter-spacing: 0.005em; }

h1, h2, h3, h4 { margin: 0; }
p { margin: 0 0 0.75em 0; }
p:last-child { margin-bottom: 0; }

.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

/* ---------- Layout shell ---------- */

.shell { min-height: 100dvh; display: flex; }

.sidebar {
  position: fixed;
  left: 0; top: 0;
  height: 100%;
  width: 240px;
  background: var(--bg-sidebar);
  border-right: var(--border-subtle);
  z-index: 56;
  display: flex;
  flex-direction: column;
  transition: transform 500ms var(--ease-standard);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  height: 64px;
  flex-shrink: 0;
  padding: 0 16px;
  border-bottom: 1px solid rgba(42,51,41,0.06);
}
.sidebar-logo a {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}
.sidebar-logo a:hover { text-decoration: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  text-decoration: none;
  transition: all 150ms ease;
}
.nav-item:hover {
  background: var(--bg-overlay);
  color: var(--text-primary);
  text-decoration: none;
}
.nav-item.active {
  background: var(--bg-overlay);
  color: var(--text-primary);
  font-weight: 600;
  border-left: 3px solid var(--accent-sage);
}
.nav-item svg { flex-shrink: 0; }

.sidebar-foot {
  padding: 16px;
  border-top: 1px solid rgba(42,51,41,0.06);
}
.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.progress-label .pct { font-size: 12px; font-weight: 600; color: var(--accent-sage); }
.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(42,51,41,0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent-sage);
  border-radius: var(--radius-full);
  transition: width 800ms ease-out;
}
.sidebar-foot .foot-note { margin-top: 10px; font-size: 12px; color: var(--text-tertiary); line-height: 1.5; }

.main {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
}

.page {
  animation: pageIn 250ms var(--ease-standard) both;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile */
.hamburger {
  position: fixed;
  top: 16px; left: 16px;
  z-index: 60;
  display: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-sidebar);
  border: var(--border-subtle);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  color: var(--text-primary);
}
.scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(4px);
  display: none;
}

@media (max-width: 767px) {
  .hamburger { display: block; }
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { display: block; }
  body.nav-open .sidebar-logo { padding-left: 60px; }
  .main { margin-left: 0; padding: 16px; padding-top: 64px; }
}
@media (max-width: 639px) {
  .display-md { font-size: 23px; }
  .display-lg { font-size: 29px; }
  .page-head .subtitle, .page-head .pills { margin-left: 0; }
  .page-head-row { align-items: flex-start; }
  .card { padding: 18px; }
  .acc-head { flex-wrap: wrap; gap: 8px; padding: 14px 16px; }
  .acc-head .acc-title { flex: 1 1 100%; }
  .acc-head .chev { margin-left: auto; }
  .acc-inner-pad { padding: 4px 16px 16px; }
  .step { padding: 10px 12px; }
  .est-total { font-size: 28px; }
  .tl-phase-head { padding-left: 48px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .main { padding: 24px; }
}

/* ---------- Page header (PartHeader pattern) ---------- */

.page-head { margin-bottom: 24px; }
.page-head-row { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.badge-letter {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.page-head .subtitle { margin-left: 48px; font-size: 15px; color: var(--text-secondary); }
.page-head .pills { margin: 8px 0 0 48px; display: flex; flex-wrap: wrap; gap: 8px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-sm);
  background: rgba(42,51,41,0.06);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.01em;
  font-weight: 500;
  color: var(--text-secondary);
}
.pill-full { border-radius: var(--radius-full); }
.pill-gold { background: var(--gold-50); color: var(--accent-gold); }
.pill-sage { background: var(--sage-100); color: var(--accent-sage); }
.pill-terracotta { background: var(--terracotta-50); color: var(--accent-terracotta); }
.pill-sky { background: var(--sky-50); color: #4A7489; }
.pill-sand { background: var(--sand-50); color: #B3895E; }
.pill-lavender { background: var(--lavender-50); color: #70668A; }
.pill-rose { background: var(--rose-50); color: #A86262; }

/* ---------- Cards ---------- */

.card {
  background: var(--bg-card);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: transform 250ms var(--ease-standard), box-shadow 250ms var(--ease-standard);
}
.card.hoverable:hover, a.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.card.flush { padding: 0; }
.card.accent { border-left: 3px solid var(--card-accent, var(--accent-sage)); }
a.card { display: block; color: inherit; }

.card-grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1023px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 639px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.stat { font-family: var(--font-mono); }
.stat .num { font-size: 28px; font-weight: 500; line-height: 1.2; color: var(--text-primary); display: block; }
.stat .lbl { font-size: 12px; color: var(--text-tertiary); letter-spacing: 0.01em; }

.callout {
  border-left: 3px solid var(--accent-sand);
  background: var(--bg-card);
  border-top: var(--border-subtle);
  border-right: var(--border-subtle);
  border-bottom: var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 15px;
  color: var(--text-secondary);
}
.callout.warn { border-left-color: var(--accent-terracotta); }
.callout.good { border-left-color: var(--accent-sage); }
.callout.info { border-left-color: var(--accent-sky); }
.callout strong { color: var(--text-primary); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  line-height: 1.55;
}
table.data th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.01em;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 10px 14px;
  border-bottom: 1px solid rgba(42,51,41,0.12);
  white-space: nowrap;
}
table.data td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(42,51,41,0.08);
  vertical-align: top;
  color: var(--text-primary);
}
table.data tr:last-child td { border-bottom: none; }
table.data td .mono, .mono { font-family: var(--font-mono); font-size: 13px; }
table.data tr:hover td { background: var(--bg-overlay); }

/* ---------- Accordion (progressive disclosure) ---------- */

.acc {
  background: var(--bg-card);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.acc + .acc { margin-top: 12px; }
.acc.accent { border-left: 3px solid var(--card-accent, var(--accent-sage)); }
.acc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px 20px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  color: var(--text-primary);
  transition: background 150ms ease;
}
.acc-head:hover { background: var(--bg-overlay); }
.acc-head .acc-title { font-size: 18px; line-height: 1.35; font-weight: 600; flex: 1; }
.acc-head .acc-sub { font-size: 13px; color: var(--text-secondary); display: block; font-weight: 400; margin-top: 2px; }
.acc-head .chev {
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: transform 200ms ease-out;
}
.acc[data-open="true"] .chev { transform: rotate(180deg); }
.acc-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 200ms ease-out;
}
.acc[data-open="true"] .acc-body { grid-template-rows: 1fr; }
.acc-body > .acc-inner { overflow: hidden; }
.acc-inner-pad { padding: 4px 20px 20px; }

/* ---------- Buttons and toggles ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  letter-spacing: 0.01em;
  font-weight: 500;
  font-family: var(--font-sans);
  border: var(--border-default);
  background: #fff;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 300ms ease;
}
.btn:hover { background: var(--bg-overlay); }
.btn.dark { background: var(--bg-dark); color: #fff; border-color: var(--bg-dark); box-shadow: var(--shadow-md); }
.btn.dark:hover { background: #3a4539; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(42,51,41,0.06);
}
.switch-row:last-child { border-bottom: none; }
.switch-row .q { font-size: 15px; color: var(--text-primary); }
.switch-row .q small { display: block; font-size: 13px; color: var(--text-secondary); font-weight: 400; }

.switch {
  position: relative;
  width: 40px; height: 22px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: rgba(42,51,41,0.15);
  border: none;
  cursor: pointer;
  transition: background 200ms ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: var(--radius-full);
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 200ms var(--ease-standard);
}
.switch[aria-pressed="true"] { background: var(--accent-sage); }
.switch[aria-pressed="true"]::after { transform: translateX(18px); }
.switch:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* Status badges driven by the requirements panel */
.req-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-full);
  padding: 2px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.req-badge.required { background: var(--terracotta-50); color: var(--accent-terracotta); }
.req-badge.waived { background: var(--sage-100); color: var(--accent-sage); }
.req-badge.conditional { background: var(--gold-50); color: var(--accent-gold); }
.req-badge.na { background: rgba(42,51,41,0.06); color: var(--text-tertiary); }

/* ---------- Pathway timeline ---------- */

.timeline { position: relative; padding: 4px 0; }
.timeline::before {
  content: "";
  position: absolute;
  left: 17px; top: 20px; bottom: 20px;
  width: 2px;
  background: rgba(42,51,41,0.15);
}

.tl-phase { position: relative; }
.tl-phase + .tl-phase { margin-top: 12px; }
.tl-phase-head {
  position: relative;
  padding: 6px 0 6px 56px;
  min-height: 44px;
}
.phase-dot {
  position: absolute;
  left: 0; top: 4px;
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 0 0 4px var(--bg-primary);
}
.tl-phase-head .tl-phase-title { font-size: 19px; font-weight: 600; line-height: 1.3; }
.tl-phase-head .tl-phase-sub { font-size: 14px; color: var(--text-secondary); margin-top: 1px; }
.tl-phase-head .tl-phase-meta { position: absolute; right: 0; top: 10px; }

.step {
  position: relative;
  margin-left: 40px;
  padding: 12px 16px 12px 16px;
  background: var(--bg-card);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.step + .step { margin-top: 8px; }
.step input[type="checkbox"] {
  appearance: none;
  width: 20px; height: 20px;
  position: absolute;
  left: -32px; top: 14px;
  border: 1.5px solid rgba(42,51,41,0.3);
  border-radius: var(--radius-full);
  background: #fff;
  cursor: pointer;
  transition: all 150ms ease;
  box-shadow: 0 0 0 4px var(--bg-primary);
}
.step input[type="checkbox"]:checked {
  background: var(--accent-sage);
  border-color: var(--accent-sage);
}
.step input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px; top: 2.5px;
  width: 4px; height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.step input[type="checkbox"]:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.step label { cursor: pointer; display: block; }
.step label > span:first-child { font-size: 15px; font-weight: 500; }
.step .step-note { font-size: 14px; line-height: 1.55; color: var(--text-secondary); display: block; margin-top: 3px; font-weight: 400; }
.step.done { border-left: 3px solid var(--accent-sage); }
.step.done label > span:first-child { color: var(--text-secondary); text-decoration: line-through; }

/* ---------- Misc ---------- */

.rule-list { margin: 0; padding-left: 1.6em; }
.rule-list li { margin: 0.35em 0; }

.waive {
  background: rgba(74,124,89,0.07);
  border: 1px solid rgba(74,124,89,0.18);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin: 4px 0 14px;
}
.waive .waive-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  font-weight: 500;
  color: var(--accent-sage);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.waive ul, .waive ol { margin: 0; padding-left: 1.4em; font-size: 14.5px; line-height: 1.55; }
.waive li { margin: 0.3em 0; }
.waive p { font-size: 14.5px; margin: 0; }

blockquote {
  border-left: 3px solid var(--accent-sand);
  margin: 0.75em 0;
  padding: 0.3em 0 0.3em 1em;
  color: var(--text-secondary);
  font-style: italic;
}

code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(42,51,41,0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

.divider { border: none; border-top: 1px solid rgba(42,51,41,0.12); margin: 24px 0; }

.section { margin-bottom: 28px; }
.section-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin-bottom: 12px;
}
.section-title .tick { color: var(--accent-sage); }

.footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid rgba(42,51,41,0.08);
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.custom-scrollbar::-webkit-scrollbar { width: 4px; height: 4px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: rgba(74, 124, 89, 0.25); border-radius: 9999px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: rgba(74, 124, 89, 0.4); }

/* Two-tier diagram (overview) */
.tier-flow { display: grid; grid-template-columns: 1fr; gap: 0; }
.tier-box {
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  background: #fff;
}
.tier-box.dark { background: var(--bg-dark); color: var(--text-inverse); border-color: var(--bg-dark); }
.tier-box .tier-tag { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.01em; color: var(--text-tertiary); }
.tier-box.dark .tier-tag { color: #9BA394; }
.tier-connector {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 6px 20px;
  color: var(--text-tertiary);
  font-size: 12px;
}
.tier-connector::before {
  content: "";
  width: 2px;
  height: 28px;
  background: rgba(42,51,41,0.2);
  margin-right: 8px;
}

/* Cost estimator */
.est-total {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.2;
}
.est-total small { font-size: 13px; color: var(--text-tertiary); display: block; font-weight: 400; }
.est-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; border-bottom: 1px solid rgba(42,51,41,0.06); }
.est-line:last-child { border-bottom: none; }
.est-line .amt { font-family: var(--font-mono); white-space: nowrap; }
.est-line.off { color: var(--text-tertiary); text-decoration: line-through; }
