:root {
  --cream: #faf6ef;
  --cream-dim: #f1ebdf;
  --charcoal: #3a362e;
  --charcoal-muted: #706a5c;
  --sage: #7a8b6f;
  --sage-tint: #e7ebe3;
  --lavender: #9b8aa6;
  --lavender-tint: #ece8ef;
  --mustard: #d6a84a;
  --mustard-tint: #f6ecd7;
  --terracotta: #c17a5a;
  --terracotta-tint: #f3e4dc;

  --font-serif: Georgia, ui-serif, Cambria, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --sidebar-width: 270px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--cream);
  color: var(--charcoal);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
}

a {
  color: var(--sage);
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Layout */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--cream-dim);
  border-right: 1px solid rgba(58, 54, 46, 0.08);
  padding: 1rem;
  overflow-y: auto;
}

.sidebar-home {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--charcoal);
  text-decoration: none;
  margin-bottom: 1.75rem;
}

.sidebar-home:hover {
  color: var(--sage);
}

.sidebar-group + .sidebar-group {
  margin-top: 1.5rem;
}

.sidebar-group-label {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--charcoal-muted);
  margin: 0 0 0.6rem;
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  padding: 0.45rem 0.6rem;
  border-radius: 0.5rem;
  text-decoration: none;
  color: var(--charcoal);
}

.sidebar-item:hover {
  background: var(--sage-tint);
  color: var(--charcoal);
}

.sidebar-item.active {
  background: var(--sage);
  color: var(--sage-tint);
}

.sidebar-item-title {
  font-size: 0.9rem;
  line-height: 1.3;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.specimen-label,
.specimen-body {
  width: 100%;
  max-width: 700px;
}

/* Specimen label header */

.specimen-label h1, .mobile-bar h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  line-height: 1.2;
  margin: 0;
  text-wrap: balance;
  max-width: 700px;
}

.specimen-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2.5rem;
  margin: 1rem 0 0 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(58, 54, 46, 0.12);
}

.specimen-field dt {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--charcoal-muted);
  margin-bottom: 0.35rem;
}

.specimen-field dd {
  margin: 0;
}

.specimen-field dd a {
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  text-decoration: none;
}

.specimen-field dd .link-text {
  text-decoration: underline;
}

/* Body content */

.specimen-body {
  margin-top: 1rem;
  font-size: 1rem;
}

.specimen-body > :first-child {
  margin-top: 0;
}

.specimen-body p {
  margin: 0 0 1.1rem;
}

.specimen-body h1,
.specimen-body h2,
.specimen-body h3,
.specimen-body h4,
.specimen-body h5,
.specimen-body h6 {
  font-family: var(--font-serif);
  line-height: 1.3;
  color: var(--charcoal);
}

.specimen-body h1 {
  font-size: 1.6rem;
  margin: 2.25rem 0 1rem;
}

.specimen-body h2 {
  font-size: 1.35rem;
  margin: 2rem 0 0.75rem;
}

.specimen-body h3 {
  font-size: 1.15rem;
  margin: 1.75rem 0 0.6rem;
}

.specimen-body h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.5rem 0 0.5rem;
}

.specimen-body h5 {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
}

.specimen-body h6 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--charcoal-muted);
  margin: 1.25rem 0 0.5rem;
}

/* Whatever sits right before a heading gives up its own trailing margin, so
   the heading's top margin alone sets the gap instead of the two adding up. */
.specimen-body :is(p, ul, ol, .photo-row, h1, h2, h3, h4, h5, h6):has(+ :is(h1, h2, h3, h4, h5, h6)) {
  margin-bottom: 0;
}

.specimen-body ul,
.specimen-body ol {
  margin: 0 0 1.1rem;
  padding-left: 1.4rem;
}

.photo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.75rem 0;
}

.specimen-body figure {
  margin: 0;
}

.specimen-body img {
  max-height: 220px;
  width: auto;
  max-width: 100%;
  border-radius: 0.25rem;
  display: block;
}

.specimen-body figcaption {
  font-size: 0.8rem;
  color: var(--charcoal-muted);
  margin-top: 0.5rem;
}

/* Mobile header bar + drawer */

.mobile-bar {
  display: none;
}

.drawer-toggle {
  display: none;
}

.drawer-overlay {
  display: none;
}

@media (max-width: 820px) {
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 15;
    background: var(--cream);
  }

  /* The bar now owns its own top/bottom breathing room via padding above, so
     .content no longer needs to contribute a top gap, and whichever element
     would normally supply the first gap below the bar is stood down to avoid
     stacking two 1rem gaps into one unnaturally large one. */
  .content {
    padding-top: 0;
  }

  .mobile-bar + .specimen-label .specimen-meta {
    margin-top: 0;
  }

  .mobile-bar + .specimen-label:not(:has(.specimen-meta)) + .specimen-body {
    margin-top: 0;
  }

  .specimen-label h1 {
    display: none;
  }

  .drawer-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.28rem;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    background: none;
    border: 1px solid rgba(58, 54, 46, 0.15);
    border-radius: 0.5rem;
  }

  .drawer-toggle-bar {
    width: 1.05rem;
    height: 2px;
    background: var(--charcoal);
    border-radius: 1px;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 25;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 2px 0 12px rgba(58, 54, 46, 0.12);
  }

  .drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(58, 54, 46, 0.35);
    z-index: 20;
  }

  .drawer-overlay.visible {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}
