.title-with-help,
.label-with-help,
.control-with-help,
.summary-with-help {
  display: flex;
  align-items: center;
  gap: 7px;
}

.title-with-help > h1,
.title-with-help > h2,
.title-with-help > h3,
.label-with-help > span,
.summary-with-help > span {
  margin-bottom: 0;
}

.generator-title { margin-bottom: 12px; }
.workspace-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.workspace-subheading { margin: 4px 0 9px; }
.routine-history-wrap { position: relative; }
.routine-history-wrap > .info-button { position: absolute; z-index: 2; top: 13px; right: 15px; }
.routine-history-wrap .routine-history > summary { padding-right: 32px; }

.label-with-help {
  justify-content: flex-start;
  margin-bottom: 5px;
  color: #395148;
  font-size: .82rem;
  font-weight: 680;
}

.label-with-help + input,
.label-with-help + select,
.label-with-help + textarea {
  margin-top: 0;
}

.info-button {
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin: 0;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong, #bdccc3);
  border-radius: 50%;
  background: var(--paper, #fff);
  color: var(--green, #276448);
  font: 700 12px/1 Georgia, serif;
  text-transform: lowercase;
  cursor: pointer;
  vertical-align: middle;
}

.info-button:hover,
.info-button[aria-expanded="true"] {
  border-color: var(--green, #276448);
  background: var(--green-soft, #e8f2ec);
}

.info-button:focus-visible,
.help-popover-close:focus-visible,
.help-popover summary:focus-visible {
  outline: 3px solid rgba(39, 100, 72, .2);
  outline-offset: 2px;
}

.help-popover {
  position: fixed;
  z-index: 1400;
  width: min(390px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - 24px));
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line-strong, #bdccc3);
  border-radius: 13px;
  background: var(--paper, #fff);
  color: var(--ink, #18322a);
  box-shadow: 0 18px 55px rgba(16, 42, 32, .2);
}

.help-popover-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.help-popover-title {
  margin: 0;
  color: var(--ink, #18322a);
  font-size: 1.05rem;
  line-height: 1.3;
}

.help-popover-close {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  margin: -6px -7px 0 0;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted, #667a72);
  font: 400 1.45rem/1 sans-serif;
  cursor: pointer;
}

.help-popover-close:hover { background: var(--green-soft, #e8f2ec); }
.help-popover-summary,
.help-popover-why { margin: 0; color: var(--muted, #667a72); font-size: .88rem; line-height: 1.5; }
.help-popover details { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line, #d8e2dc); }
.help-popover summary { color: var(--green, #276448); font-size: .84rem; font-weight: 700; cursor: pointer; }
.help-popover ul { margin: 9px 0 0; padding-left: 19px; color: var(--muted, #667a72); font-size: .84rem; line-height: 1.48; }
.help-popover li + li { margin-top: 7px; }
.help-popover-why { margin-top: 9px; }

@media (max-width: 600px) {
  .help-popover {
    inset: auto 12px 12px 12px !important;
    width: auto;
    max-height: min(70vh, 620px);
    border-radius: 15px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .help-popover:not([hidden]) { animation: help-in .12s ease-out; }
  @keyframes help-in { from { opacity: 0; transform: translateY(4px); } }
}
