.sb-saved-task-modal {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: rgba(18, 18, 20, 0.42);
  opacity: 0;
  transition: opacity 180ms ease;
}

.sb-saved-task-modal[hidden] {
  display: none;
}

.sb-saved-task-modal.show {
  opacity: 1;
}

.sb-saved-task-save-dialog,
.sb-saved-task-library-dialog {
  position: relative;
  width: min(100%, 430px);
  max-height: min(760px, calc(100dvh - 48px));
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  opacity: 0;
  transform: scale(0.97) translateY(8px);
  transition: opacity 200ms ease, transform 220ms cubic-bezier(0.23, 1, 0.32, 1);
}

.sb-saved-task-library-dialog {
  width: min(100%, 700px);
}

.sb-saved-task-modal.show .sb-saved-task-save-dialog,
.sb-saved-task-modal.show .sb-saved-task-library-dialog {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.sb-saved-task-save-dialog > header,
.sb-saved-task-library-dialog > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 14px;
}

.sb-saved-task-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
}

.sb-saved-task-save-dialog h3,
.sb-saved-task-library-dialog h3 {
  margin: 0;
  color: var(--text);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
}

.sb-saved-task-library-tools svg,
.sb-saved-task-empty svg,
.sb-saved-task-row-actions svg,
.sb-saved-task-preview-empty svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sb-saved-task-primary:active,
.sb-saved-task-row-actions button:active,
.sb-saved-task-delete-confirm button:active {
  transform: scale(0.97);
}

.sb-saved-task-primary:focus-visible,
.sb-saved-task-row-actions button:focus-visible,
.sb-saved-task-delete-confirm button:focus-visible {
  outline: 2px solid #e1ac00;
  outline-offset: 2px;
}

.sb-saved-task-field input:focus,
.sb-saved-task-field input:focus-visible {
  outline: none;
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.035);
}

.sb-saved-task-library-tools input:focus,
.sb-saved-task-library-tools input:focus-visible {
  outline: none;
}

.sb-saved-task-library-tools label:focus-within {
  border-color: rgba(0, 0, 0, 0.2);
}

.sb-saved-task-field {
  display: grid;
  gap: 7px;
  padding: 10px 20px 0;
}

.sb-saved-task-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.sb-saved-task-field input,
.sb-saved-task-library-tools input {
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.sb-saved-task-field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 650;
  text-transform: uppercase;
}

.sb-saved-task-field input[aria-invalid="true"] {
  border-color: #e64e52;
}

.sb-saved-task-message {
  min-height: 18px;
  margin: 0;
  padding: 7px 20px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.sb-saved-task-message:empty {
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.sb-saved-task-message[data-state="error"] {
  color: #d83b40;
}

.sb-saved-task-message[data-state="success"] {
  color: #248944;
}

.sb-saved-task-message[data-state="busy"] {
  color: var(--text);
}

.sb-saved-task-save-dialog > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px 20px;
}

.sb-saved-task-close-after {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.sb-saved-task-close-after input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: #e9b900;
}

.sb-saved-task-primary {
  min-width: 84px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid #e1ac00;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffe477 0%, #ffd13f 58%, #f0b900 100%);
  color: #332800;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 140ms ease, transform 140ms cubic-bezier(0.23, 1, 0.32, 1), opacity 140ms ease;
}

.sb-saved-task-primary:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

@media (hover: hover) and (pointer: fine) {
  .sb-saved-task-primary:not(:disabled):hover {
    filter: brightness(1.03);
  }
}

.sb-saved-task-library-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 20px 12px;
}

.sb-saved-task-library-tools label {
  height: 40px;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
}

.sb-saved-task-library-tools input {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
}

.sb-saved-task-library-tools > span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.sb-saved-task-list {
  min-height: 220px;
  overflow-y: auto;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.sb-saved-task-row {
  min-height: 88px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  box-sizing: border-box;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.sb-saved-task-preview {
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--soft);
}

.sb-saved-task-preview img,
.sb-saved-task-preview-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
  color: var(--muted);
}

.sb-saved-task-row-main {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.sb-saved-task-row-main strong {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-saved-task-row-main span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.sb-saved-task-row-actions,
.sb-saved-task-delete-confirm {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.sb-saved-task-row-actions button,
.sb-saved-task-delete-confirm button {
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease, transform 140ms cubic-bezier(0.23, 1, 0.32, 1);
}

.sb-saved-task-row-delete {
  width: 34px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: transparent;
  color: var(--muted);
}

.sb-saved-task-row-restore {
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--bg);
  color: var(--text);
}

.sb-saved-task-delete-confirm > span {
  color: #d83b40;
  font-size: 12px;
  white-space: nowrap;
}

.sb-saved-task-delete-confirm button {
  padding: 0 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--bg);
  color: var(--text);
}

.sb-saved-task-delete-confirm button[data-delete-confirm] {
  border-color: #e64e52;
  background: #e64e52;
  color: #fff;
}

@media (hover: hover) and (pointer: fine) {
  .sb-saved-task-row-delete:hover {
    border-color: rgba(216, 59, 64, 0.35);
    color: #d83b40;
    background: rgba(216, 59, 64, 0.08);
  }

  .sb-saved-task-row-restore:hover,
  .sb-saved-task-delete-confirm button:not([data-delete-confirm]):hover {
    background: var(--soft);
  }
}

.sb-saved-task-empty {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
}

.sb-saved-task-empty > svg {
  width: 28px;
  height: 28px;
}

.sb-saved-task-empty p {
  margin: 0;
  font-size: 13px;
}

.sb-saved-task-spinner {
  width: 22px;
  height: 22px;
  box-sizing: border-box;
  border: 2px solid rgba(127, 127, 127, 0.22);
  border-top-color: #e1ac00;
  border-radius: 50%;
  animation: sb-saved-task-spin 700ms linear infinite;
}

@keyframes sb-saved-task-spin {
  to { transform: rotate(360deg); }
}

html.theme-dark .sb-saved-task-save-dialog,
html.theme-dark .sb-saved-task-library-dialog {
  border-color: rgba(255, 255, 255, 0.1);
}

html.theme-dark .sb-saved-task-field input,
html.theme-dark .sb-saved-task-library-tools label,
html.theme-dark .sb-saved-task-list,
html.theme-dark .sb-saved-task-row,
html.theme-dark .sb-saved-task-row-delete,
html.theme-dark .sb-saved-task-row-restore,
html.theme-dark .sb-saved-task-delete-confirm button {
  border-color: rgba(255, 255, 255, 0.11);
}

html.theme-dark .sb-saved-task-field input:focus,
html.theme-dark .sb-saved-task-field input:focus-visible,
html.theme-dark .sb-saved-task-library-tools label:focus-within {
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: none;
}

@media (max-width: 620px) {
  .sb-saved-task-modal {
    align-items: flex-end;
    padding: 12px;
  }

  .sb-saved-task-save-dialog,
  .sb-saved-task-library-dialog {
    width: 100%;
    max-height: calc(100dvh - 24px);
    border-radius: 14px;
  }

  .sb-saved-task-row {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 11px;
    padding: 11px 14px;
  }

  .sb-saved-task-preview {
    width: 54px;
    height: 54px;
  }

  .sb-saved-task-row-actions,
  .sb-saved-task-delete-confirm {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .sb-saved-task-save-dialog > footer {
    align-items: flex-end;
  }

  .sb-saved-task-close-after {
    line-height: 1.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sb-saved-task-modal,
  .sb-saved-task-save-dialog,
  .sb-saved-task-library-dialog {
    transition: opacity 120ms ease;
    transform: none;
  }
}
