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

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

/* ACCORDION CONTAINER: fixed height, flex column */
.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;              /* <-- fixed height */
  display: flex;
  flex-direction: column;
}

/* Each section is a flex column and can grow/shrink */
.accordion-section {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0; /* important so inner flex items can shrink */
}

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

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

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

/* Always-open header (section 2) */
.accordion-header.always-open {
  cursor: default;
}

/* PANELS
   - closed: flex:0, no height
   - open: flex:1, fills remaining space in the section
*/
.accordion-panel {
  padding: 0 1.25rem;
  overflow: hidden;
  flex: 0 1 auto;
  opacity: 0;
  transition:
    flex 0.25s ease,
    opacity 0.25s ease,
    padding-top 0.25s ease,
    padding-bottom 0.25s ease;
}

/* When open, the panel expands and can scroll inside */
.accordion-panel.open {
  flex: 1 1 auto;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  opacity: 1;
  overflow: auto; /* scroll content if taller than available space */
}

/* Basic content styling */
.accordion-panel p {
  margin: 0 0 0.75rem;
}