.question-collapsible-sections {
  display: grid;
  gap: 12px;
}
.question-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-left: auto;
  margin-right: 8px;
}
.question-card-badges span {
  border: 2px solid rgba(54, 43, 31, 0.35);
  border-radius: 8px;
  padding: 3px 7px;
  background: rgba(255,255,255,0.7);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}
.question-inner-section,
.structured-note-section {
  border: 2px solid rgba(54, 43, 31, 0.18);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.38);
}
.section-caret-header,
.block-caret-header {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px;
  cursor: pointer;
  text-align: left;
}
.section-caret-header {
  min-height: 32px;
}
.section-caret-box {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border: 2px solid rgba(54, 43, 31, 0.72);
  border-radius: 4px;
  background: rgba(255, 249, 230, 0.92);
  box-shadow: 2px 2px 0 rgba(54, 43, 31, 0.18);
  line-height: 1;
  font-weight: 900;
  flex: 0 0 auto;
}
.section-small-hint {
  font-size: 0.78rem;
  color: #6b5a4d;
  font-weight: 700;
}
.section-collapsed {
  padding-bottom: 10px;
}
.structured-section-title {
  gap: 10px;
}
.block-caret-header {
  flex: 1;
  min-width: 0;
}
.block-caret-header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.block-collapsed {
  padding-bottom: 10px;
}
.graph-block {
  border-style: solid;
}
.graph-upload-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}
.graph-upload-button {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.graph-upload-button input.graph-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.ghost-button {
  background: rgba(255,255,255,0.75);
}
.graph-dropzone {
  border: 2px dashed rgba(112, 87, 61, 0.55);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,0.72);
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  min-height: 120px;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.graph-dropzone.dragging,
.graph-dropzone:focus {
  outline: none;
  border-color: #7c5cff;
  background: rgba(124, 92, 255, 0.08);
  transform: translateY(-1px);
}
.graph-empty-state {
  display: grid;
  gap: 4px;
  color: #5b4634;
}
.graph-empty-state span,
.graph-helper-text {
  font-size: 0.88rem;
  color: #6b5a4d;
}
.graph-preview-image {
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(112, 87, 61, 0.22);
  background: #fff;
}
.graph-thumb {
  width: 34px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid rgba(54,43,31,.24);
  background: #fff;
  flex: 0 0 auto;
}
.export-graph-grid {
  display: grid;
  gap: 12px;
}
.export-graph-card {
  break-inside: avoid;
  border: 1px solid #d5ccb8;
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0;
}
.export-graph-card img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 8px 0;
  border-radius: 8px;
}
@media (max-width: 720px) {
  .question-card-header {
    align-items: flex-start;
  }
  .question-card-badges {
    width: 100%;
    margin-left: 0;
    order: 3;
  }
  .section-caret-header,
  .block-caret-header {
    width: 100%;
  }
}
body.night-mode .question-card-badges span,
body.night-mode .section-caret-box,
body.night-mode .ghost-button {
  background: rgba(29, 35, 53, 0.88);
  color: #eef3ff;
  border-color: rgba(190, 205, 255, 0.28);
}
body.night-mode .question-inner-section,
body.night-mode .structured-note-section,
body.night-mode .graph-dropzone {
  background: rgba(20, 25, 40, 0.9);
  border-color: rgba(190, 205, 255, 0.22);
}
body.night-mode .graph-empty-state,
body.night-mode .graph-empty-state span,
body.night-mode .graph-helper-text,
body.night-mode .section-small-hint {
  color: #d8e0ff;
}
body.night-mode .graph-preview-image,
body.night-mode .graph-thumb {
  background: #0d1324;
  border-color: rgba(190, 205, 255, 0.16);
}

/* v1.5.1.1: controlled optional fields so Extra Note / Full Citation can always close again */
.controlled-optional {
  border: 2px dashed rgba(112, 87, 61, 0.32);
  border-radius: 12px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.45);
}
.optional-summary-button {
  width: 100%;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  font: inherit;
  font-weight: 800;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.optional-summary-button:hover {
  transform: none;
  box-shadow: none;
}
.controlled-optional label {
  margin-top: 8px;
}
body.night-mode .controlled-optional {
  background: rgba(20, 25, 40, 0.72);
  border-color: rgba(190, 205, 255, 0.22);
}
