label:last-child > :last-child {
  margin-bottom: 0;
}

div.form-label:last-child > :last-child {
  margin-bottom: 0;
}

/* Remove excess margins from Markdown-generated <p> tags inside form labels, legends and input labels. */
.form-checkbox p,
.form-label p,
.form-radio p,
legend p {
  margin: 0;
}

/*
Spectre removes the fieldset border, bring it back for the outermost fieldset
(and also integrate it with Spectre's design).
*/
form > fieldset {
  border: 0.05rem solid rgb(188, 195, 206);
  border-radius: 0.1rem;
  padding: 0.4rem;
}

/* Don't display last hr as it is not needed and only clutters the layout. */
form > fieldset > hr:last-child {
  display: none;
}

form fieldset > legend {
  padding-inline: 0.4rem;
}

pre > code:only-child {
  display: block;
}

.clf-content-block {
  margin-block: 0.8rem;
}

/* Width of the required indicator (icon + gap). Used to align inputs with the label text. */
:root {
  --clf-required-indent: 1rem;
}

.clf-fa-required {
  --fa: "\f621";
  align-items: center;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 0.625em;
  width: var(--clf-required-indent);
}

/* Align required indicator side-by-side with label text (which may contain block-level <p> from Markdown). */
.form-checkbox > span:has(.clf-fa-required),
.form-label:has(> .clf-fa-required),
legend:has(> .clf-fa-required) {
  display: flex;
  align-items: baseline;
}

/*
 * When a required indicator is present, indent the entire form-group / fieldset
 * so that labels, inputs, radios and checkboxes all align with the label text.
 * The indicator uses negative margin to sit in the indent space.
 */
.form-group:has(.clf-fa-required) {
  padding-left: var(--clf-required-indent);
}

fieldset:has(> legend > .clf-fa-required) {
  padding-left: var(--clf-required-indent);
}

.form-group .clf-fa-required,
legend > .clf-fa-required {
  margin-left: calc(-1 * var(--clf-required-indent));
}

/* Prevent code blocks from expanding beyond their container. */
.code {
  overflow: hidden;
}

/* Wrap long lines instead of horizontal scroll. */
.code code {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* Each logical line is a block with a hanging indent for visual distinction of wrapped continuations. */
.clf-code-line {
  display: block;
  padding-left: 1.2em;
  text-indent: -1.2em;
}

/* Preserve height of empty lines. */
.clf-code-line:empty {
  min-height: 1.5em;
}

/* Show wrap indicator icon on continuation lines when wrapping has occurred. */
.clf-code-line.clf-wrapped {
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='16'><text x='0' y='13' font-size='13' fill='%23bcc3ce' font-family='sans-serif'>↳</text></svg>");
  background-position: 0.1em 1.5em;
  background-size: 0.9em 1.5em;
  background-repeat: repeat-y;
}

.clf-code-copy-btn {
  position: absolute;
  right: 0.2rem;
  top: 0.2rem;
}

/* Move code block language indicator to the left */
.code::before {
  left: 0.5rem;
  top: 0.3rem;
}

/* Give the code block language indicator more space */
.code[data-lang] code {
  padding-top: 1.6rem;
}

li p {
  display: inline-flex;
}

/* This styling is missing from spectre (only implemented for .form-input) */
:is(
  .form-checkbox:has(input:invalid) > .form-icon,
  .form-radio:has(input:invalid) > .form-icon,
  .form-select:invalid
) {
  border-color: #e85600;
}

/* Style inline code similar to spectre's code blocks. Also fixes low contrast. */
:not(pre) > code {
  background-color: #f7f8f9;
  color: #3b4351;
  display: inline-block; /* NEVER break inline code (it looks ugly and it is hard to differentiate from two separate inline code blocks */
  margin-inline: 0.1rem;
}

pre:has(code) {
  margin-top: 0;
}

.step .step-item.skipped a::before,
.step .step-item.skipped button::before {
  background-color: #bcc3ce;
}

.step .step-item.skipped a,
.step .step-item.skipped button {
  color: #bcc3ce;
  text-decoration: line-through;
}

/* Make inputs work in the steps component */
.step .step-item button {
  background: none;
  border: none;
  color: #5755d9;
  display: inline-block;
  padding: 20px 10px 0;
  text-decoration: none;
}

.step .step-item button:hover {
  cursor: pointer;
}

.step .step-item button::before {
  background: #5755d9;
  border: .1rem solid #fff;
  border-radius: 50%;
  content: "";
  display: block;
  height: .6rem;
  left: 50%;
  position: absolute;
  top: .2rem;
  transform: translateX(-50%);
  width: .6rem;
  z-index: 1;
}

.step .step-item.active button::before {
  background: #fff;
  border: .1rem solid #5755d9;
}

.step .step-item.active ~ .step-item button {
  color: #bcc3ce;
}

.step .step-item.active ~ .step-item button::before {
  background: #dadee4;
}

.toast {
  margin-block: 0.8rem;
}

/* Better multiline alignment for (text) lists. */
:is(ol, ul):not([class]) li {
  list-style-position: outside;
  margin-left: 0.8rem;
}

.clf-sortable {
  cursor: pointer;
  user-select: none;
}
