#form-dialog {
  max-height: calc(100vh - 28px);
  overflow: hidden;
}

#form-dialog form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 28px);
  overflow: hidden;
}

#form-dialog .dialog-fields {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#form-dialog form > header,
#form-dialog form > footer {
  flex: none;
}

/* Pickers escape the modal's scroll container so the catalogue can expand
   over the viewport instead of being clipped inside the small dialog. */
.combobox-list {
  position: fixed;
  max-height: min(360px, 55vh);
  overflow-y: auto;
}

.target-summary {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.combobox-wrap { min-width: 0; }
.target-error { display: block; margin-top: 3px; color: var(--red); font: 700 10px var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.target-action-text { display: none; }

.route-table td:first-child .meta-line { display: block; }

.attempt-sequence {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
}

.activity-attempt {
  display: grid;
  grid-template-columns: 19px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  padding: 3px 5px;
  border: 1px solid #d8e1e8;
  border-radius: 3px;
  white-space: nowrap;
}

.attempt-failed { border-color: #e7c2c1; background: #fff8f8; }
.attempt-success { border-color: #b9ddca; background: #f4fbf7; }
.attempt-neutral { border-color: #cdd5db; background: #f5f7f9; }
.attempt-cooldown { border-color: #cdd5db; background: #f5f7f9; }
.attempt-number { color: #6b8193; font: 700 10px var(--mono); }
.attempt-route { min-width: 0; }
.attempt-route code { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.attempt-status { font: 700 11px var(--mono); }
.attempt-failed[data-error-key], .attempt-cooldown[data-error-key], .attempt-neutral[data-error-key] { cursor: pointer; }
.attempt-failed[data-error-key]:hover { background: #f8e8e7; }
.attempt-failed[data-error-key]:hover .attempt-status { text-decoration: underline; }
.attempt-cooldown[data-error-key]:hover { background: #eef2f5; }
.attempt-cooldown[data-error-key]:hover .attempt-status { text-decoration: underline; }
.attempt-neutral[data-error-key]:hover { background: #eef2f5; }
.attempt-neutral[data-error-key]:hover .attempt-status { text-decoration: underline; }
.activity-detail-pending { display: inline-block; margin-left: 5px; color: var(--muted); font: 700 11px var(--mono); animation: activity-pending-pulse 1s ease-in-out infinite; }
@keyframes activity-pending-pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
.activity-attempts-error { display: inline-block; margin-left: 6px; font-size: 11px; }
.activity-retry { margin-left: 6px; padding: 0; border: 0; background: none; color: var(--blue); font: 700 11px var(--mono); cursor: pointer; text-decoration: underline; }
.activity-retry:hover { color: var(--blue-dark); }
.error-dialog { width: min(560px, calc(100vw - 30px)); }
.error-dialog > section { display: flex; flex-direction: column; }
.error-content { padding: 18px 22px 0; }
.error-content pre { margin: 0; padding: 12px 14px; background: #f2f5f7; border: 1px solid var(--line); border-radius: 3px; max-height: 40vh; overflow: auto; }
.error-content code { display: block; color: var(--ink); font-family: var(--mono); font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.error-dialog .copy-state { margin: 10px 22px 0; }
.attempt-failed .attempt-status { color: var(--red); }
.attempt-success .attempt-status { color: var(--green); }
.attempt-neutral .attempt-status { color: var(--muted); }
.attempt-cooldown .attempt-status { color: var(--muted); }
.fallback-label { display: block; margin-top: 4px; color: var(--red); font: 700 10px var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.fallback-hint { display: block; margin: 6px 0 10px; color: var(--muted); font-size: 11px; line-height: 1.5; }

.routing-targets[data-fallback-targets] {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
}

.routing-targets[data-fallback-targets] .target-row {
  grid-template-columns: 28px minmax(0, 1fr) 34px auto;
  padding: 10px 0;
}

.routing-targets[data-fallback-targets] .target-enable {
  min-height: 34px;
}

.routing-targets[data-fallback-targets] .target-actions button {
  font-weight: 700;
}

@media (max-width: 720px) {
  #form-dialog:not(.route-picker-dialog) {
    max-height: 92vh;
  }

  #form-dialog:not(.route-picker-dialog) form {
    max-height: 92vh;
  }

  .routing-targets[data-fallback-targets] {
    padding: 8px;
  }

  .routing-targets[data-fallback-targets] .target-row {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: 6px;
  }

  .routing-targets[data-fallback-targets] .target-actions {
    grid-column: 2 / 4;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    padding-top: 4px;
  }

  .routing-targets[data-fallback-targets] .target-actions button {
    height: 35px;
    border: 1px solid var(--line);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }

  .routing-targets[data-fallback-targets] .target-action-glyph {
    font-size: 16px;
  }

  .routing-targets[data-fallback-targets] .target-action-text {
    display: inline;
    font: 700 9px var(--mono);
    letter-spacing: .03em;
    text-transform: uppercase;
  }
}
