*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  margin: 2rem;
  background: #f5f5f5;
}

/* ACCORDION: fixed height container */
.accordion {
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

  height: 800px;
  display: flex;
  flex-direction: column;
  overflow-y: auto; /* allow scroll if content exceeds 800px */
}

/* SECTIONS — do NOT force equal heights */
.accordion-section {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto; /* <-- important: size according to content */
  min-height: 0;
}

.accordion-section + .accordion-section {
  border-top: 1px solid #e0e0e0;
}

/* HEADERS */
.accordion-header {
  width: 100%;
  text-align: left;
  padding: 1rem 1.25rem;
  background: #fafafa;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}

.accordion-header:hover:not(.always-open) {
  background: #f0f0f0;
}

.accordion-header.always-open {
  cursor: default;
}

/* PANELS — closed: height:0, open: auto height */
.accordion-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;

  padding: 0 1.25rem;
  transition:
    max-height 0.3s ease,
    opacity 0.3s ease,
    padding-top 0.3s ease,
    padding-bottom 0.3s ease;
}

/* When open, panel expands to fit content */
.accordion-panel.open {
  max-height: 2000px; /* sufficiently large to reveal content */
  opacity: 1;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  overflow-y: auto;
}