:root {
  --bristol-green: #00491e;
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;

  --border-subtle: #e0e0e5;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow-soft: 0 14px 30px rgba(15, 23, 42, 0.06);

  --text-main: #111827;
  --text-muted: #4b5563;
  --text-soft: #6b7280;

  --info: #14532d;
  --info-soft: #dcfce7;
  --info-strong: #064e3b;

  --danger: #b91c1c;
  --danger-soft: #fee2e2;

  --warn: #b45309;
  --warn-soft: #fef3c7;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
               sans-serif;
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

.layout {
  display: flex;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  gap: 24px;
  flex: 1;
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  width: 48px;
  height: 48px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 0;
  box-shadow: var(--shadow-soft);
  transition: background 0.2s;
  font-size: 24px;
  line-height: 1;
}

.mobile-menu-toggle:hover {
  background: var(--bg);
}

.mobile-menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-main);
  border-radius: 1px;
  transition: opacity 0.3s;
}

.mobile-menu-toggle.active span {
  opacity: 0;
}

.mobile-menu-toggle::before {
  content: '✕';
  position: absolute;
  color: var(--text-main);
  opacity: 0;
  transition: opacity 0.3s;
  font-weight: 300;
}

.mobile-menu-toggle.active::before {
  opacity: 1;
}

/* Sidebar nav */
.sidebar {
  position: sticky;
  top: 16px;
  align-self: flex-start;
  flex: 0 0 240px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 18px 18px 14px;
  font-size: 0.9rem;
}

.sidebar h2 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-soft);
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar li {
  margin-bottom: 6px;
}

.sidebar a {
  display: block;
  padding: 4px 8px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, transform 0.08s;
}

.sidebar a:hover {
  background: var(--info-soft);
  color: var(--info-strong);
  transform: translateX(2px);
}

.nav-arrow {
  display: inline-block;
  font-size: 10px;
  margin-right: 6px;
  transition: transform 0.2s;
  width: 12px;
}

.sidebar a.collapsed .nav-arrow {
  transform: rotate(-90deg);
}

.sidebar .sub {
  padding-left: 14px;
  font-size: 0.85em;
  margin-top: 4px;
  margin-bottom: 2px;
}

.sidebar .sub-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  max-height: 500px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}

.sidebar .sub-list.collapsed {
  max-height: 0;
  opacity: 0;
}

/* Main content */
main {
  flex: 1 1 auto;
  max-width: 780px;
  margin: 0 auto;
}

.page {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-subtle);
  padding: 28px 26px 28px;
}

@media (max-width: 860px) {
  .mobile-menu-toggle {
    display: flex;
  }

  .layout {
    flex-direction: column;
    padding: 16px 10px 28px;
    padding-top: 70px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    max-width: 100%;
    order: -1;
    z-index: 999;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 70px 18px 18px;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .page {
    padding: 22px 18px 22px;
  }
}

@media (max-width: 480px) {
  .layout {
    padding: 16px 8px 28px;
    padding-top: 70px;
  }

  .page {
    padding: 16px 12px 16px;
    border-radius: var(--radius-md);
  }

  .section-content {
    padding: 18px 14px;
  }

  .figure--float-right {
    float: none;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 16px;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 4px 6px;
  }
}

header.page-header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.page-title {
  margin: 0;
  font-size: 2.5rem;
  letter-spacing: .01em;
  color: var(--bristol-green);
}

.page-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.96rem;
}

.section {
  margin-bottom: 28px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
  border-bottom: 1px solid var(--border-subtle);
}

.section-header:hover {
  background: #ececf1;
}

.section-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform 0.2s;
  font-size: 14px;
}

.section.collapsed .section-toggle {
  transform: rotate(-90deg);
}

.section h2 {
  margin: 0;
  font-size: 1.25rem;
  scroll-margin-top: 90px;
}

.section-content {
  padding: 28px 26px;
  background: var(--bg-elevated);
  max-height: 10000px;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}

.section.collapsed .section-content {
  max-height: 0;
  padding: 0 26px;
  opacity: 0;
  overflow: hidden;
}

.section h3 {
  margin: 0 0 12px;
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--bristol-green);
  scroll-margin-top: 90px;
  border-bottom: 3px solid var(--bristol-green);
  padding-bottom: 8px;
}

.section h3:not(:first-of-type) {
  margin-top: 24px;
}

.section h4 {
  margin: 18px 0 8px;
  font-size: 1rem;
  font-weight: 600;
  text-transform: none;
}

p {
  margin: 0 0 10px;
  color: var(--text-main);
}

strong {
  font-weight: 600;
}

em {
  font-style: italic;
}

a {
  color: var(--info);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--info-strong);
}

ul, ol {
  padding-left: 1.2rem;
  margin: 6px 0 10px;
}

li {
  margin-bottom: 4px;
}

/* Callouts */
.callout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  margin: 8px 0 12px;
}

.callout-icon {
  font-size: 1.2rem;
  line-height: 1;
  padding-top: 1px;
}

.callout-body {
  color: var(--text-main);
}

.callout-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.callout--ok {
  background: var(--info-soft);
  border-color: var(--info);
}

.callout--danger {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.callout--warn {
  background: var(--warn-soft);
  border-color: var(--warn);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 14px;
  font-size: 0.9rem;
  overflow: hidden;
  border-radius: var(--radius-md);
}

thead {
  background: #f3f4f6;
}

th, td {
  border: 1px solid var(--border-subtle);
  padding: 6px 8px;
  vertical-align: top;
}

th {
  text-align: left;
  font-weight: 600;
}

tbody tr:nth-child(even) {
  background: #fafafa;
}

.subtle {
  color: var(--text-soft);
  font-size: 0.88rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.88em;
  background: #f3f4f6;
  padding: 2px 4px;
  border-radius: 4px;
}

hr {
  border: none;
  border-top: 1px dashed var(--border-subtle);
  margin: 20px 0 16px;
}

/* Figures / images */
.figure {
  margin: 18px 0 20px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  background: #fff;
}

.figure--wide {
  margin-left: -6px;
  margin-right: -6px;
}

.figure--float-right {
  float: right;
  max-width: 50%;
  margin-left: 20px;
  margin-right: 0;
  margin-top: 0;
  margin-bottom: 16px;
}

.figure img {
  display: block;
  width: 100%;
  height: auto;
}

.figure-body {
  padding: 10px 14px 12px;
}

.figure-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 4px;
}

.figure-caption {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin: 0;
}

.figure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0px;
  margin: 0px 0 0px;
}

.figure-grid-item {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  background: #fff;
}

.figure-grid-item img {
  display: block;
  width: 100%;
  height: auto;
}
